Navigation Menu

Skip to content

Commit

Permalink
vec: add missing out-of-memory check
Browse files Browse the repository at this point in the history
Closes #19305
  • Loading branch information
thestinger committed Nov 25, 2014
1 parent 48ca6d1 commit c9816be
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/libcollections/vec.rs
Expand Up @@ -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 }
}
}
Expand Down

0 comments on commit c9816be

Please sign in to comment.