about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2014-09-05 06:19:15 -0400
committerDaniel Micay <danielmicay@gmail.com>2014-09-06 13:58:34 -0400
commit2fdad65a057d9b6cd159623ebeba131ec32f69dd (patch)
treefca30e9e8a772e89d6d64177696c2bba84cda39f /src/libsyntax
parentd1bd139251be4b1c51ace8d180757ca7b59e675a (diff)
downloadrust-2fdad65a057d9b6cd159623ebeba131ec32f69dd.tar.gz
rust-2fdad65a057d9b6cd159623ebeba131ec32f69dd.zip
fix sized deallocation for OwnedSlice
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/owned_slice.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libsyntax/owned_slice.rs b/src/libsyntax/owned_slice.rs
index 7eb6709919a..d368477cd33 100644
--- a/src/libsyntax/owned_slice.rs
+++ b/src/libsyntax/owned_slice.rs
@@ -58,9 +58,12 @@ impl<T> OwnedSlice<T> {
         if len == 0 {
             OwnedSlice::empty()
         } else {
+            // drop excess capacity to avoid breaking sized deallocation
+            v.shrink_to_fit();
+
             let p = v.as_mut_ptr();
             // we own the allocation now
-            unsafe {mem::forget(v)}
+            unsafe { mem::forget(v) }
 
             OwnedSlice { data: p, len: len }
         }