Skip to content

Commit f74bb8b

Browse files
committed
Fix panic when parsing DWARF 2 line info for empty section
May as well remove both unwraps :p
1 parent 62b7a22 commit f74bb8b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

objdiff-core/src/obj/read.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,9 @@ fn line_info(obj_file: &File<'_>, sections: &mut [ObjSection], obj_data: &[u8])
431431
let mut text_sections =
432432
obj_file.sections().filter(|s| s.kind() == SectionKind::Text);
433433
let section_index = text_sections.next().map(|s| s.index().0);
434-
let mut lines = section_index.map(|index| {
435-
&mut sections.iter_mut().find(|s| s.orig_index == index).unwrap().line_info
436-
});
434+
let mut lines = section_index
435+
.and_then(|index| sections.iter_mut().find(|s| s.orig_index == index))
436+
.map(|s| &mut s.line_info);
437437

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

0 commit comments

Comments
 (0)