use checked multiplication in heap_index! macro

This commit is contained in:
Skgland
2025-12-07 21:31:24 +01:00
committed by Bennet Bleßmann
parent 2fc08dde1e
commit d63b0a192c

View File

@@ -471,11 +471,16 @@ macro_rules! resource_error_call_result {
}
macro_rules! heap_index {
($idx:expr) => {
($idx:expr) => {{
let idx = $idx;
std::mem::size_of::<HeapCellValue>()
.checked_mul($idx)
.unwrap()
};
.checked_mul(idx)
.expect(&format!(
"overflow while calculating heap index {idx} * {} > {}",
std::mem::size_of::<HeapCellValue>(),
usize::MAX,
))
}};
}
macro_rules! cell_index {