diff options
Diffstat (limited to 'rust/src')
| -rw-r--r-- | rust/src/low_level_il/function.rs | 3 | ||||
| -rw-r--r-- | rust/src/medium_level_il/function.rs | 9 |
2 files changed, 6 insertions, 6 deletions
diff --git a/rust/src/low_level_il/function.rs b/rust/src/low_level_il/function.rs index 8af89652..2eaf7f11 100644 --- a/rust/src/low_level_il/function.rs +++ b/rust/src/low_level_il/function.rs @@ -106,7 +106,8 @@ where ) -> Option<LowLevelInstructionIndex> { use binaryninjacore_sys::BNLowLevelILGetInstructionStart; let loc: Location = loc.into(); - let arch = loc.arch.unwrap_or_else(|| *self.arch().as_ref()); + // If the location does not specify an architecture, use the function's architecture. + let arch = loc.arch.unwrap_or_else(|| self.arch()); let instr_idx = unsafe { BNLowLevelILGetInstructionStart(self.handle, arch.handle, loc.addr) }; // `instr_idx` will equal self.instruction_count() if the instruction is not valid. 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 |
