Skip to content

Commit 62b7a22

Browse files
committed
Fix panic when parsing DWARF 2 line info for empty section
1 parent 9ca157d commit 62b7a22

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

objdiff-core/src/obj/read.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -444,13 +444,9 @@ fn line_info(obj_file: &File<'_>, sections: &mut [ObjSection], obj_data: &[u8])
444444
// The next row is the start of a new sequence, which means we must
445445
// advance to the next .text section.
446446
let section_index = text_sections.next().map(|s| s.index().0);
447-
lines = section_index.map(|index| {
448-
&mut sections
449-
.iter_mut()
450-
.find(|s| s.orig_index == index)
451-
.unwrap()
452-
.line_info
453-
});
447+
lines = section_index
448+
.and_then(|index| sections.iter_mut().find(|s| s.orig_index == index))
449+
.map(|s| &mut s.line_info);
454450
}
455451
}
456452
}

0 commit comments

Comments
 (0)