From cf937b0be9d49f74b9df12c768212a3363207429 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Sun, 11 Aug 2024 16:54:24 -0600 Subject: [PATCH] Guard against symbols larger than section --- objdiff-core/src/diff/data.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/objdiff-core/src/diff/data.rs b/objdiff-core/src/diff/data.rs index 262edf9..c429dcb 100644 --- a/objdiff-core/src/diff/data.rs +++ b/objdiff-core/src/diff/data.rs @@ -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 =