debug: Avoid underflow when scanning for landing pad bytes (#2866)

This commit is contained in:
Benjamin Bouvier
2021-05-03 18:58:40 +02:00
committed by GitHub
parent dfb1bc4d02
commit 8811246a9f

View File

@@ -512,9 +512,11 @@ where
}
};
}
// Find all landing pads by scanning bytes, do not care about
// false location at this moment.
// Looks hacky but it is fast; does not need to be really exact.
if buf.len() > 2 {
for i in 0..buf.len() - 2 {
let op = buf[i];
if op == gimli::constants::DW_OP_bra.0 || op == gimli::constants::DW_OP_skip.0 {
@@ -530,6 +532,8 @@ where
}
}
}
}
while !pc.is_empty() {
let unread_bytes = pc.len().into_u64();
if let Some(marker) = jump_targets.get(&unread_bytes) {