Skip to content

Commit 85d31f2

Browse files
committed
More None checks when querying IL internal to API
1 parent 21a7b5e commit 85d31f2

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

python/basicblock.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,19 +252,23 @@ def il_function(self) -> Optional['_function.ILFunctionType']:
252252
elif il_type == _function.FunctionGraphType.LiftedILFunctionGraph:
253253
return func.lifted_il
254254
elif il_type == _function.FunctionGraphType.LowLevelILSSAFormFunctionGraph:
255-
return func.low_level_il.ssa_form
255+
func_llil = func.low_level_il
256+
return func_llil.ssa_form if func_llil is not None else None
256257
elif il_type == _function.FunctionGraphType.MediumLevelILFunctionGraph:
257258
return func.medium_level_il
258259
elif il_type == _function.FunctionGraphType.MediumLevelILSSAFormFunctionGraph:
259-
return func.medium_level_il.ssa_form
260+
func_mlil = func.medium_level_il
261+
return func_mlil.ssa_form if func_mlil is not None else None
260262
elif il_type == _function.FunctionGraphType.MappedMediumLevelILFunctionGraph:
261263
return func.mapped_medium_level_il
262264
elif il_type == _function.FunctionGraphType.MappedMediumLevelILSSAFormFunctionGraph:
263-
return func.mapped_medium_level_il.ssa_form
265+
func_mmlil = func.mapped_medium_level_il
266+
return func_mmlil.ssa_form if func_mmlil is not None else None
264267
elif il_type == _function.FunctionGraphType.HighLevelILFunctionGraph:
265268
return func.high_level_il
266269
elif il_type == _function.FunctionGraphType.HighLevelILSSAFormFunctionGraph:
267-
return func.high_level_il.ssa_form
270+
func_hlil = func.high_level_il
271+
return func_hlil.ssa_form if func_hlil is not None else None
268272
elif il_type == _function.FunctionGraphType.HighLevelLanguageRepresentationFunctionGraph:
269273
return func.high_level_il
270274
else:

python/function.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2948,7 +2948,11 @@ def clear_user_var_value(self, var: 'variable.Variable', def_addr: int, after: b
29482948
# Special case: function parameters have index 0 and are defined at the start of the function
29492949
def_addr = self.start
29502950
else:
2951-
var_defs = self.mlil.get_var_definitions(var)
2951+
func_mlil = self.mlil
2952+
if func_mlil is None:
2953+
raise ValueError("Could not get definition for Variable")
2954+
2955+
var_defs = func_mlil.get_var_definitions(var)
29522956
if var_defs is None:
29532957
raise ValueError("Could not get definition for Variable")
29542958

python/lineardisassembly.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ def _from_core_struct(cls, struct: core.BNLinearDisassemblyLine, obj: Optional['
5959
if obj.identifier.name == "HLIL Function Body":
6060
il_func = function.hlil
6161
elif obj.identifier.name == "HLIL SSA Function Body":
62-
il_func = function.hlil.ssa_form
62+
func_hlil = function.hlil
63+
if func_hlil is not None:
64+
il_func = func_hlil.ssa_form
6365
elif obj.identifier.name == "Language Representation Function Body":
6466
il_func = function.hlil
6567

0 commit comments

Comments
 (0)