Uh oh!
There was an error while loading. Please reload this page.
alloc_system: Handle failure properly - #32997
Merged
bors merged 1 commit intoApr 16, 2016
Merged
Conversation
The Unix implementation was incorrectly handling failure for reallocation of over-aligned types by not checking for NULL. Closesrust-lang#32993
rust-highfive
commented
Apr 15, 2016
Contributor
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
alexcrichton
commented
Apr 15, 2016
MemberAuthor
r? @brson |
| deallocate(ptr, old_size, align); | ||
| if !new_ptr.is_null() { | ||
| ptr::copy(ptr, new_ptr, cmp::min(size, old_size)); | ||
| deallocate(ptr, old_size, align); |
Member
There was a problem hiding this comment.
We should deallocate this memory despite of failure in allocating new_ptr.
Member
There was a problem hiding this comment.
Oh, never mind me.
The manual for realloc says:
If the area pointed to was moved, a free(ptr) is done.
and
If realloc() fails, the original block is left untouched; it is not freed or moved.
So it is required for memory to not get freed if move fails.
nagisa
commented
Apr 15, 2016
Member
r=me with comment fixed. |
nagisa
commented
Apr 15, 2016
Member
Manishearth added a commit
to Manishearth/rust
that referenced
this pull request
Apr 15, 2016
…id-this-land, r=nagisa alloc_system: Handle failure properly The Unix implementation was incorrectly handling failure for reallocation of over-aligned types by not checking for NULL. Closesrust-lang#32993
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Unix implementation was incorrectly handling failure for reallocation of
over-aligned types by not checking for NULL.
Closes#32993