From c9816be35a1bcdef915498939a1f62c18dee1c04 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Tue, 25 Nov 2014 11:18:31 -0500 Subject: [PATCH] vec: add missing out-of-memory check Closes #19305 --- src/libcollections/vec.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index a3291e01942..e239125244f 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -165,6 +165,7 @@ impl Vec { let size = capacity.checked_mul(mem::size_of::()) .expect("capacity overflow"); let ptr = unsafe { allocate(size, mem::min_align_of::()) }; + if ptr.is_null() { ::alloc::oom() } Vec { ptr: ptr as *mut T, len: 0, cap: capacity } } }