Skip to content

Commit

Permalink
Guard against symbols larger than section
Browse files Browse the repository at this point in the history
  • Loading branch information
encounter committed Aug 11, 2024
1 parent 23b6d33 commit cf937b0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions objdiff-core/src/diff/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ pub fn diff_data_section(
right_section_diff: &ObjSectionDiff,
) -> Result<(ObjSectionDiff, ObjSectionDiff)> {
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 right_max = right.symbols.iter().map(|s| s.section_address + s.size).max().unwrap_or(0);
let left_max =
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 right_data = &right.data[..right_max as usize];
let ops =
Expand Down

0 comments on commit cf937b0

Please sign in to comment.