Guard against symbols larger than section

This commit is contained in:
Luke Street 2024-08-11 16:54:24 -06:00
parent 23b6d33a98
commit cf937b0be9
1 changed files with 4 additions and 2 deletions

View File

@ -48,8 +48,10 @@ pub fn diff_data_section(
right_section_diff: &ObjSectionDiff, right_section_diff: &ObjSectionDiff,
) -> Result<(ObjSectionDiff, ObjSectionDiff)> { ) -> Result<(ObjSectionDiff, ObjSectionDiff)> {
let deadline = Instant::now() + Duration::from_secs(5); let deadline = Instant::now() + Duration::from_secs(5);
let left_max = left.symbols.iter().map(|s| s.section_address + s.size).max().unwrap_or(0); let left_max =
let right_max = right.symbols.iter().map(|s| s.section_address + s.size).max().unwrap_or(0); left.symbols.iter().map(|s| s.section_address + s.size).max().unwrap_or(0).min(left.size);
let right_max =
right.symbols.iter().map(|s| s.section_address + s.size).max().unwrap_or(0).min(right.size);
let left_data = &left.data[..left_max as usize]; let left_data = &left.data[..left_max as usize];
let right_data = &right.data[..right_max as usize]; let right_data = &right.data[..right_max as usize];
let ops = let ops =