From: Skgland Date: Sun, 7 Dec 2025 21:59:00 +0000 (+0100) Subject: handle overflown in Heap::with_cell_capacity X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=47e908bf76851c0afd018b30ee8d2ed53fe53316;p=scryer-prolog.git handle overflown in Heap::with_cell_capacity --- 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();