]> Repositorios git - scryer-prolog.git/commitdiff
handle overflown in Heap::with_cell_capacity
authorSkgland <[email protected]>
Sun, 7 Dec 2025 21:59:00 +0000 (22:59 +0100)
committerBennet Bleßmann <[email protected]>
Sun, 7 Dec 2025 21:59:00 +0000 (22:59 +0100)
src/machine/heap.rs

index 3d614ebbba657f1d1c61dd032588fcbabf8bc640..c93d005b4675fc21d27bf0a4b68cd525767a970f 100644 (file)
@@ -599,7 +599,7 @@ impl Heap {
     pub(crate) fn with_cell_capacity(cap: usize) -> Result<Self, AllocError> {
         let ptr = unsafe {
             let layout = alloc::Layout::from_size_align(
-                cap * size_of::<HeapCellValue>(),
+                heap_index_checked!(cap).ok_or(AllocError)?,
                 size_of::<HeapCellValue>(),
             )
             .unwrap();