about summary refs log tree commit diff
path: root/src/liballoc_system
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-04-15 14:51:16 -0700
committerbors <bors@rust-lang.org>2016-04-15 14:51:16 -0700
commit576229fea054105f1f3a49ca5f31f5f4983f5266 (patch)
tree736d1a8f05d181f27e51d53ef49e4d77e05bb861 /src/liballoc_system
parent9debf51f4b8a5d437df1abca57c5a58c45297b60 (diff)
parente563359396928453db81141bf12dae04a567f2e9 (diff)
downloadrust-576229fea054105f1f3a49ca5f31f5f4983f5266.tar.gz
rust-576229fea054105f1f3a49ca5f31f5f4983f5266.zip
Auto merge of #33005 - Manishearth:rollup, r=Manishearth
Rollup of 11 pull requests

- Successful merges: #32923, #32926, #32929, #32931, #32935, #32945, #32946, #32964, #32970, #32973, #32997
- Failed merges:
Diffstat (limited to 'src/liballoc_system')
-rw-r--r--src/liballoc_system/lib.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/liballoc_system/lib.rs b/src/liballoc_system/lib.rs
index 6a62e00d311..ca4c9bfd954 100644
--- a/src/liballoc_system/lib.rs
+++ b/src/liballoc_system/lib.rs
@@ -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
         }
     }