vec: add missing out-of-memory check

Closes #19305
This commit is contained in:
Daniel Micay 2014-11-25 11:18:31 -05:00
parent 48ca6d1840
commit c9816be35a

View File

@ -165,6 +165,7 @@ impl<T> Vec<T> {
let size = capacity.checked_mul(mem::size_of::<T>())
.expect("capacity overflow");
let ptr = unsafe { allocate(size, mem::min_align_of::<T>()) };
if ptr.is_null() { ::alloc::oom() }
Vec { ptr: ptr as *mut T, len: 0, cap: capacity }
}
}