@@ -131,8 +131,8 @@ def _collect_xrefs_from_inst(bv, inst, ref_eas, reftype=XrefType.XREF_NONE):
131131 if not isinstance (inst , bn .LowLevelILInstruction ):
132132 return
133133
134- assert not is_unimplemented (bv , inst )
135- assert not is_undef ( bv , inst )
134+ if is_unimplemented (bv , inst ) or is_undef ( bv , inst ):
135+ return
136136
137137 if is_function_call (bv , inst ) or is_jump (bv , inst ):
138138 reftype = XrefType .XREF_CONTROL_FLOW
@@ -384,6 +384,10 @@ def visit(self, program, is_definition, add_refs_as_defs):
384384 # if the function is a declaration, then Anvill only needs to know its symbols and prototypes
385385 # if its a definition, then Anvill will perform analysis of the function and produce information for the func
386386 for ref_ea in ref_eas :
387+ # If ref_ea is an invalid address
388+ seg = program ._bv .get_segment_at (ref_ea )
389+ if seg is None :
390+ continue
387391 program .try_add_referenced_entity (ref_ea , add_refs_as_defs )
388392
389393 def _extract_types_mlil (
@@ -514,6 +518,11 @@ def get_variable_impl(self, address):
514518 """Given an address, return a `Variable` instance, or
515519 raise an `InvalidVariableException` exception."""
516520
521+ # raise exception if the variable has invalid address
522+ seg = self ._bv .get_segment_at (address )
523+ if seg is None :
524+ raise InvalidVariableException ("Invalid variable address" )
525+
517526 arch = self ._arch
518527 bn_var = self ._bv .get_data_var_at (address )
519528 var_type = get_type (bn_var .type )
0 commit comments