diff options
| author | Mason Reed <mason@vector35.com> | 2025-05-31 10:45:26 -0400 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2025-05-31 10:45:26 -0400 |
| commit | 8ba8388e12ab32ad937c4514f7a907d2530f1ef8 (patch) | |
| tree | 6f63abc4605b7429a7e215eef0769d72ab0fb97a /rust/src/medium_level_il | |
| parent | c7a819799828e965b6c2afa7e8f39aecf1a5b9a7 (diff) | |
[Rust] Retrieve architecture if missing from location passed to `MediumLevelILFunction::instruction_from_index`
Fixes https://github.com/Vector35/binaryninja-api/issues/6876
Diffstat (limited to 'rust/src/medium_level_il')
| -rw-r--r-- | rust/src/medium_level_il/function.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/rust/src/medium_level_il/function.rs b/rust/src/medium_level_il/function.rs index 4206f7dd..54df3d12 100644 --- a/rust/src/medium_level_il/function.rs +++ b/rust/src/medium_level_il/function.rs @@ -47,11 +47,10 @@ impl MediumLevelILFunction { loc: L, ) -> Option<MediumLevelInstructionIndex> { let loc: Location = loc.into(); - let arch = loc - .arch - .map(|a| a.handle) - .unwrap_or_else(std::ptr::null_mut); - let instr_idx = unsafe { BNMediumLevelILGetInstructionStart(self.handle, arch, loc.addr) }; + // If the location does not specify an architecture, use the function's architecture. + let arch = loc.arch.unwrap_or_else(|| self.function().arch()); + let instr_idx = + unsafe { BNMediumLevelILGetInstructionStart(self.handle, arch.handle, loc.addr) }; // `instr_idx` will equal self.instruction_count() if the instruction is not valid. if instr_idx >= self.instruction_count() { None |
