Skip to content

Commit

Permalink
Fix panic when parsing DWARF 2 line info for empty section
Browse files Browse the repository at this point in the history
May as well remove both unwraps :p
  • Loading branch information
AetiasHax committed Oct 19, 2024
1 parent 62b7a22 commit f74bb8b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions objdiff-core/src/obj/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,9 @@ fn line_info(obj_file: &File<'_>, sections: &mut [ObjSection], obj_data: &[u8])
let mut text_sections =
obj_file.sections().filter(|s| s.kind() == SectionKind::Text);
let section_index = text_sections.next().map(|s| s.index().0);
let mut lines = section_index.map(|index| {
&mut sections.iter_mut().find(|s| s.orig_index == index).unwrap().line_info
});
let mut lines = section_index
.and_then(|index| sections.iter_mut().find(|s| s.orig_index == index))
.map(|s| &mut s.line_info);

let mut rows = program.rows();
while let Some((_header, row)) = rows.next_row()? {
Expand Down

0 comments on commit f74bb8b

Please sign in to comment.