Add a memory map bound check assertion on rendering const slice

This commit is contained in:
Shoyu Vanilla 2025-07-11 23:44:49 +09:00
parent 4b2593085d
commit f6e11e8248

View File

@ -795,6 +795,14 @@ fn render_const_scalar(
let Some(bytes) = memory_map.get(addr, size_one * count) else {
return f.write_str("<ref-data-not-available>");
};
let expected_len = count * size_one;
if bytes.len() < expected_len {
never!(
"Memory map size is too small. Expected {expected_len}, got {}",
bytes.len(),
);
return f.write_str("<layout-error>");
}
f.write_str("&[")?;
let mut first = true;
for i in 0..count {