Allow `None` section when parsing line info

Fixes an error upon ending the last DWARF sequence
This commit is contained in:
Aetias 2024-05-21 18:07:58 +02:00 committed by Luke Street
parent 94f1f07b00
commit 31e9c14681
1 changed files with 8 additions and 9 deletions

View File

@ -346,15 +346,14 @@ fn line_info(obj_file: &File<'_>, sections: &mut [ObjSection]) -> Result<()> {
if row.end_sequence() { if row.end_sequence() {
// The next row is the start of a new sequence, which means we must // The next row is the start of a new sequence, which means we must
// advance to the next .text section. // advance to the next .text section.
let section_index = text_sections let section_index = text_sections.next().map(|s| s.index().0);
.next() lines = section_index.map(|index| {
.ok_or_else(|| anyhow!("Next text section not found for line info"))? &mut sections
.index() .iter_mut()
.0; .find(|s| s.orig_index == index)
lines = sections .unwrap()
.iter_mut() .line_info
.find(|s| s.orig_index == section_index) });
.map(|s| &mut s.line_info);
} }
} }
} }