File tree Expand file tree Collapse file tree 3 files changed +20
-6
lines changed Expand file tree Collapse file tree 3 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -142,7 +142,10 @@ pub unsafe extern "C" fn BNWARPIsLiftedInstructionVariant(
142142 unsafe { LowLevelILFunction :: from_raw ( analysis_function) } ;
143143 match lifted_il. instruction_from_index ( index) {
144144 Some ( instr) => {
145- let relocatable_regions = relocatable_regions ( & lifted_il. function ( ) . view ( ) ) ;
145+ let Some ( owner_function) = lifted_il. function ( ) else {
146+ return false ;
147+ } ;
148+ let relocatable_regions = relocatable_regions ( & owner_function. view ( ) ) ;
146149 is_variant_instruction ( & relocatable_regions, & instr)
147150 }
148151 None => false ,
@@ -158,7 +161,10 @@ pub unsafe extern "C" fn BNWARPIsLowLevelInstructionComputedVariant(
158161 unsafe { LowLevelILFunction :: from_raw ( analysis_function) } ;
159162 match llil. instruction_from_index ( index) {
160163 Some ( instr) => {
161- let relocatable_regions = relocatable_regions ( & llil. function ( ) . view ( ) ) ;
164+ let Some ( owner_function) = llil. function ( ) else {
165+ return false ;
166+ } ;
167+ let relocatable_regions = relocatable_regions ( & owner_function. view ( ) ) ;
162168 is_computed_variant_instruction ( & relocatable_regions, & instr)
163169 }
164170 None => false ,
Original file line number Diff line number Diff line change @@ -48,7 +48,11 @@ impl HighlightRenderLayer {
4848 llil : & LowLevelILRegularFunction ,
4949 lines : & mut [ DisassemblyTextLine ] ,
5050 ) {
51- let relocatable_regions = relocatable_regions ( & lifted_il. function ( ) . view ( ) ) ;
51+ let Some ( owner_function) = lifted_il. function ( ) else {
52+ return ;
53+ } ;
54+
55+ let relocatable_regions = relocatable_regions ( & owner_function. view ( ) ) ;
5256 for line in lines {
5357 // We use address here instead of index since it's more reliable for other IL's.
5458 for lifted_il_instr in filtered_instructions_at ( lifted_il, line. address ) {
Original file line number Diff line number Diff line change 8888 }
8989
9090 pub ( crate ) fn arch ( & self ) -> CoreArchitecture {
91+ // TODO: self.function() can return None under rare circumstances
9192 match self . arch {
92- None => self . function ( ) . arch ( ) ,
93+ None => self . function ( ) . unwrap ( ) . arch ( ) ,
9394 Some ( arch) => arch,
9495 }
9596 }
@@ -167,10 +168,13 @@ where
167168 }
168169 }
169170
170- pub fn function ( & self ) -> Ref < Function > {
171+ pub fn function ( & self ) -> Option < Ref < Function > > {
171172 unsafe {
172173 let func = BNGetLowLevelILOwnerFunction ( self . handle ) ;
173- Function :: ref_from_raw ( func)
174+ if func. is_null ( ) {
175+ return None ;
176+ }
177+ Some ( Function :: ref_from_raw ( func) )
174178 }
175179 }
176180
You can’t perform that action at this time.
0 commit comments