about summary refs log tree commit diff
path: root/src/liballoc_jemalloc
diff options
context:
space:
mode:
Diffstat (limited to 'src/liballoc_jemalloc')
-rw-r--r--src/liballoc_jemalloc/lib.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/liballoc_jemalloc/lib.rs b/src/liballoc_jemalloc/lib.rs
index c10af35a94b..09666bd0e62 100644
--- a/src/liballoc_jemalloc/lib.rs
+++ b/src/liballoc_jemalloc/lib.rs
@@ -229,13 +229,14 @@ mod contents {
 
         let flags = align_to_flags(new_align);
         let ptr = rallocx(ptr as *mut c_void, new_size, flags) as *mut u8;
-        let alloc_size = sallocx(ptr as *mut c_void, flags);
         if ptr.is_null() {
             let layout = Layout::from_size_align_unchecked(new_size, new_align);
             ptr::write(err as *mut AllocErr,
                        AllocErr::Exhausted { request: layout });
+        } else {
+            let alloc_size = sallocx(ptr as *mut c_void, flags);
+            *excess = alloc_size;
         }
-        *excess = alloc_size;
         ptr
     }