Skip to content

Commit c9816be

Browse files
committed
vec: add missing out-of-memory check
Closes #19305
1 parent 48ca6d1 commit c9816be

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/libcollections/vec.rs

+1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ impl<T> Vec<T> {
165165
let size = capacity.checked_mul(mem::size_of::<T>())
166166
.expect("capacity overflow");
167167
let ptr = unsafe { allocate(size, mem::min_align_of::<T>()) };
168+
if ptr.is_null() { ::alloc::oom() }
168169
Vec { ptr: ptr as *mut T, len: 0, cap: capacity }
169170
}
170171
}

0 commit comments

Comments
 (0)