don't drop uninitialised memory when pushing to stack

This commit is contained in:
John Ericson 2015-08-26 00:24:20 -07:00 committed by edef
parent 96a31d2443
commit a1f286bdaf

View File

@ -18,7 +18,7 @@ pub unsafe fn push<T>(spp: &mut *mut usize, value: T) -> *mut T {
let mut sp = *spp as *mut T;
sp = offset_mut(sp, -1);
sp = align_down_mut(sp, max(align_of::<T>(), STACK_ALIGN));
*sp = value;
ptr::write(sp, value); // does not attempt to drop old value
*spp = sp as *mut usize;
sp
}