diff --git a/src/machine/heap.rs b/src/machine/heap.rs index 3d614ebb..c93d005b 100644 --- a/src/machine/heap.rs +++ b/src/machine/heap.rs @@ -599,7 +599,7 @@ impl Heap { pub(crate) fn with_cell_capacity(cap: usize) -> Result { let ptr = unsafe { let layout = alloc::Layout::from_size_align( - cap * size_of::(), + heap_index_checked!(cap).ok_or(AllocError)?, size_of::(), ) .unwrap();