From 3213b7b89136d01c2fc37049f06223fb273450d1 Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Mon, 11 Oct 2021 14:36:25 -0400 Subject: Fix LowLevelIL returning an invalid ILSemanticFlagClass --- python/architecture.py | 10 ++-------- python/lowlevelil.py | 6 ++++-- 2 files changed, 6 insertions(+), 10 deletions(-) (limited to 'python') diff --git a/python/architecture.py b/python/architecture.py index de28dc77..a72760ae 100644 --- a/python/architecture.py +++ b/python/architecture.py @@ -1493,10 +1493,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): """ if not isinstance(class_index, int): raise ValueError("argument 'class_index' must be an integer") - try: - return self._semantic_flag_classes_by_index[class_index] - except KeyError: - raise AttributeError("argument class_index is not a valid class index") + return self._semantic_flag_classes_by_index[class_index] def get_semantic_flag_group_index(self, sem_group:SemanticGroupType) -> SemanticGroupIndex: if isinstance(sem_group, str): @@ -1515,10 +1512,7 @@ class Architecture(metaclass=_ArchitectureMetaClass): """ if not isinstance(group_index, int): raise ValueError("argument 'group_index' must be an integer") - try: - return self._semantic_flag_groups_by_index[group_index] - except KeyError: - raise AttributeError("argument group_index is not a valid group index") + return self._semantic_flag_groups_by_index[group_index] def get_intrinsic_name(self, intrinsic:IntrinsicIndex) -> IntrinsicName: """ diff --git a/python/lowlevelil.py b/python/lowlevelil.py index 1f6914de..7105d996 100644 --- a/python/lowlevelil.py +++ b/python/lowlevelil.py @@ -865,7 +865,9 @@ class LowLevelILInstruction: architecture.RegisterStackIndex(self.instr.operands[operand_index1])) return SSARegisterStack(reg_stack, self.instr.operands[operand_index2]) - def get_sem_class(self, operand_index:int) -> ILSemanticFlagClass: + def get_sem_class(self, operand_index:int) -> Optional[ILSemanticFlagClass]: + if self.instr.operands[operand_index] == 0: + return None return ILSemanticFlagClass(self.function.arch, architecture.SemanticClassIndex(self.instr.operands[operand_index])) @@ -1915,7 +1917,7 @@ class LowLevelILFlag_cond(LowLevelILInstruction): return self.get_cond(0) @property - def semantic_class(self) -> ILSemanticFlagClass: + def semantic_class(self) -> Optional[ILSemanticFlagClass]: return self.get_sem_class(1) @property -- cgit v1.3.1