mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-25 11:17:13 +00:00
Add a memory map bound check assertion on rendering const slice
This commit is contained in:
parent
4b2593085d
commit
f6e11e8248
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user