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 alloc bug in String/Array trimming functions #2336

Merged
merged 1 commit into from
Nov 15, 2017

Conversation

dipinhora
Copy link
Contributor

Prior to this commit, the trim/trim_in_place functions of Array
and String incorrectly calculated the new _alloc value.

This commit changes the logic to set _alloc to be the same
as the new _size if the last byte is not included and to
only included extra allocated bytes if we're including the
last byte.

This commit also changes how String.from_cpointer calculates
the _alloc value as it was incorrectly adding a byte when it
shouldn't have been (this was likely due to an assumption of a
null terminator being present that doesn't hold any longer).

Tests have also been enhanced to prevent regressions.

Prior to this commit, the trim/trim_in_place functions of Array
and String incorrectly calculated the new `_alloc` value.

This commit changes the logic to set `_alloc` to be the same
as the new `_size` if the last byte is not included and to
only included extra allocated bytes if we're including the
last byte.

This commit also changes how `String.from_cpointer` calculates
the `_alloc` value as it was incorrectly adding a byte when it
shouldn't have been (this was likely due to an assumption of a
null terminator being present that doesn't hold any longer).

Tests have also been enhanced to prevent regressions.
@dipinhora dipinhora added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Nov 14, 2017
@dipinhora
Copy link
Contributor Author

NOTE: These issues were discovered while working on #2337 and that PR is not safe to implement until these bugs are fixed.

@SeanTAllen SeanTAllen merged commit b4d076b into ponylang:master Nov 15, 2017
ponylang-main added a commit that referenced this pull request Nov 15, 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