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() {
// The next row is the start of a new sequence, which means we must
// advance to the next .text section.
let section_index = text_sections
.next()
.ok_or_else(|| anyhow!("Next text section not found for line info"))?
.index()
.0;
lines = sections
let section_index = text_sections.next().map(|s| s.index().0);
lines = section_index.map(|index| {
&mut sections
.iter_mut()
.find(|s| s.orig_index == section_index)
.map(|s| &mut s.line_info);
.find(|s| s.orig_index == index)
.unwrap()
.line_info
});
}
}
}