diff options
| author | bors <bors@rust-lang.org> | 2014-08-24 07:45:59 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-08-24 07:45:59 +0000 |
| commit | 16d538cba0cc5b5830e7c17663e985d13ece8e0c (patch) | |
| tree | 294ccfb06762fd94a30f9d2f2397cae7e39e5829 /src/liballoc | |
| parent | c556ca9853961793af433b3cfe58966a68a791c5 (diff) | |
| parent | b1f7d3aaa021d626b4083ddaa706b26f3521d343 (diff) | |
| download | rust-16d538cba0cc5b5830e7c17663e985d13ece8e0c.tar.gz rust-16d538cba0cc5b5830e7c17663e985d13ece8e0c.zip | |
auto merge of #16706 : pnkfelix/rust/fsk-fix-nojem-realloc, r=thestinger
Copy only up to `min(new_size, old_size)` when doing reallocate. This was a bug when running with jemalloc disabled. Fix #16687
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/heap.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index e2faa3240ed..ab686cb01d6 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -208,6 +208,7 @@ mod imp { #[cfg(not(jemalloc), unix)] mod imp { + use core::cmp; use core::mem; use core::ptr; use libc; @@ -248,7 +249,7 @@ mod imp { pub unsafe fn reallocate(ptr: *mut u8, size: uint, align: uint, old_size: uint) -> *mut u8 { let new_ptr = allocate(size, align); - ptr::copy_memory(new_ptr, ptr as *const u8, old_size); + ptr::copy_memory(new_ptr, ptr as *const u8, cmp::min(size, old_size)); deallocate(ptr, old_size, align); return new_ptr; } |
