From 2fdad65a057d9b6cd159623ebeba131ec32f69dd Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Fri, 5 Sep 2014 06:19:15 -0400 Subject: [PATCH] fix sized deallocation for OwnedSlice --- src/libsyntax/owned_slice.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libsyntax/owned_slice.rs b/src/libsyntax/owned_slice.rs index 7eb6709919aa..d368477cd33a 100644 --- a/src/libsyntax/owned_slice.rs +++ b/src/libsyntax/owned_slice.rs @@ -58,9 +58,12 @@ impl OwnedSlice { 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 } }