mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-04 04:39:16 +00:00
Rollup merge of #32997 - alexcrichton:fix-alloc-system-how-did-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. Closes #32993
This commit is contained in:
commit
e563359396
@ -96,8 +96,10 @@ mod imp {
|
||||
libc::realloc(ptr as *mut libc::c_void, size as libc::size_t) as *mut u8
|
||||
} else {
|
||||
let new_ptr = allocate(size, align);
|
||||
ptr::copy(ptr, new_ptr, cmp::min(size, old_size));
|
||||
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);
|
||||
}
|
||||
new_ptr
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user