Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix segfault in Array.trim_in_place #1999

Merged
merged 1 commit into from
Jul 1, 2017
Merged

Conversation

SeanTAllen
Copy link
Member

This is the mirror update to Array.trim_in_place that was made
previously in String. Relevant commit comment from String:

Array.trim_in_place wasn't written to work correctly if you were
to trim the array down to nothing and then append a size less than the
"alloc" value that is left. This combination could result in incorrect
handling for arrays that end up with a size of 0.

This is because, a new pointer was created, but we retained incorrect
alloc info. This wouldn't cause an error so long as when you used the
array for something like an append, reserve allocated new memory.
However, if the appended value was less than the perceived alloc size,
no additional memory would be added and kaboom.

see 381b281

This is the mirror update to Array.trim_in_place that was made
previously in String. Relevant commit comment from String:

Array.trim_in_place wasn't written to work correctly if you were
to trim the array down to nothing and then append a size less than the
"alloc" value that is left. This combination could result in incorrect
handling for arrays that end up with a size of 0.

This is because, a new pointer was created, but we retained incorrect
alloc info. This wouldn't cause an error so long as when you used the
array for something like an append, reserve allocated new memory.
However, if the appended value was less than the perceived alloc size,
no additional memory would be added and kaboom.

see 381b281
@SeanTAllen SeanTAllen added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Jul 1, 2017
@SeanTAllen SeanTAllen requested a review from jemc July 1, 2017 22:07
@jemc jemc merged commit b12f909 into master Jul 1, 2017
@jemc jemc deleted the array-trim-in-place-segfault branch July 1, 2017 22:31
ponylang-main added a commit that referenced this pull request Jul 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants