Skip to content

Commit f2afcd4

Browse files
committed
Follow only if a call is selected
1 parent 7ef4e49 commit f2afcd4

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

src/header/formats/elf/events.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,20 @@ fn tab_program_headers_events(app: &mut App, key: KeyEvent) -> Result<bool> {
142142
// follow
143143
// TODO: follow only when a PhysAddr field is selected
144144
KeyCode::Char('f') => {
145-
let idx = app
145+
if let Some(idx) = app
146146
.header_view
147147
.elf_state
148148
.program_header_table_state
149149
.selected()
150-
.unwrap();
151-
let elf = app.header_view.elf.as_ref().unwrap();
152-
let phdr = elf.phdrs.get(idx).unwrap();
153-
let ofs = phdr.p_offset;
154-
app.goto(ofs as usize);
155-
app.editor_view = AppView::Hex;
150+
{
151+
// if we're here, the ELF should be valid (hopefully)
152+
let elf = app.header_view.elf.as_ref().unwrap();
153+
if let Some(phdr) = elf.phdrs.get(idx) {
154+
let ofs = phdr.p_offset;
155+
app.goto(ofs as usize);
156+
app.editor_view = AppView::Hex;
157+
}
158+
}
156159
}
157160
_ => {}
158161
}

0 commit comments

Comments
 (0)