]> Repositorios git - scryer-prolog.git/commitdiff
prevent multiply with overflow resulting in odd errors/segv
authorSkgland <[email protected]>
Sun, 7 Dec 2025 20:27:24 +0000 (21:27 +0100)
committerBennet Bleßmann <[email protected]>
Sun, 7 Dec 2025 20:27:24 +0000 (21:27 +0100)
src/macros.rs

index f977b88259c6e47637edc17e00489f3ef6a3ff7a..2eda4980312b65f25fd872a4bff38da5f6935c15 100644 (file)
@@ -472,7 +472,9 @@ macro_rules! resource_error_call_result {
 
 macro_rules! heap_index {
     ($idx:expr) => {
-        ($idx) * std::mem::size_of::<HeapCellValue>()
+        std::mem::size_of::<HeapCellValue>()
+            .checked_mul($idx)
+            .unwrap()
     };
 }