diff options
| -rw-r--r-- | plugins/warp/src/plugin/ffi.rs | 10 | ||||
| -rw-r--r-- | plugins/warp/src/plugin/render_layer.rs | 6 | ||||
| -rw-r--r-- | rust/src/low_level_il/function.rs | 10 |
3 files changed, 20 insertions, 6 deletions
diff --git a/plugins/warp/src/plugin/ffi.rs b/plugins/warp/src/plugin/ffi.rs index c3a8051c..2826ed34 100644 --- a/plugins/warp/src/plugin/ffi.rs +++ b/plugins/warp/src/plugin/ffi.rs @@ -142,7 +142,10 @@ pub unsafe extern "C" fn BNWARPIsLiftedInstructionVariant( unsafe { LowLevelILFunction::from_raw(analysis_function) }; match lifted_il.instruction_from_index(index) { Some(instr) => { - let relocatable_regions = relocatable_regions(&lifted_il.function().view()); + let Some(owner_function) = lifted_il.function() else { + return false; + }; + let relocatable_regions = relocatable_regions(&owner_function.view()); is_variant_instruction(&relocatable_regions, &instr) } None => false, @@ -158,7 +161,10 @@ pub unsafe extern "C" fn BNWARPIsLowLevelInstructionComputedVariant( unsafe { LowLevelILFunction::from_raw(analysis_function) }; match llil.instruction_from_index(index) { Some(instr) => { - let relocatable_regions = relocatable_regions(&llil.function().view()); + let Some(owner_function) = llil.function() else { + return false; + }; + let relocatable_regions = relocatable_regions(&owner_function.view()); is_computed_variant_instruction(&relocatable_regions, &instr) } None => false, diff --git a/plugins/warp/src/plugin/render_layer.rs b/plugins/warp/src/plugin/render_layer.rs index 6c446e6f..3417c9b1 100644 --- a/plugins/warp/src/plugin/render_layer.rs +++ b/plugins/warp/src/plugin/render_layer.rs @@ -48,7 +48,11 @@ impl HighlightRenderLayer { llil: &LowLevelILRegularFunction, lines: &mut [DisassemblyTextLine], ) { - let relocatable_regions = relocatable_regions(&lifted_il.function().view()); + let Some(owner_function) = lifted_il.function() else { + return; + }; + + let relocatable_regions = relocatable_regions(&owner_function.view()); for line in lines { // We use address here instead of index since it's more reliable for other IL's. for lifted_il_instr in filtered_instructions_at(lifted_il, line.address) { diff --git a/rust/src/low_level_il/function.rs b/rust/src/low_level_il/function.rs index 65c3536a..ca6508c9 100644 --- a/rust/src/low_level_il/function.rs +++ b/rust/src/low_level_il/function.rs @@ -88,8 +88,9 @@ where } pub(crate) fn arch(&self) -> CoreArchitecture { + // TODO: self.function() can return None under rare circumstances match self.arch { - None => self.function().arch(), + None => self.function().unwrap().arch(), Some(arch) => arch, } } @@ -167,10 +168,13 @@ where } } - pub fn function(&self) -> Ref<Function> { + pub fn function(&self) -> Option<Ref<Function>> { unsafe { let func = BNGetLowLevelILOwnerFunction(self.handle); - Function::ref_from_raw(func) + if func.is_null() { + return None; + } + Some(Function::ref_from_raw(func)) } } |
