summaryrefslogtreecommitdiff
path: root/python/highlevelil.py
diff options
context:
space:
mode:
authorJosh Ferrell <josh@vector35.com>2020-08-21 08:36:01 -0400
committerJosh Ferrell <josh@vector35.com>2020-08-21 08:36:32 -0400
commit3485769f83dbfce783df886689841db3a1544916 (patch)
tree2ea36f8d93770f8db586ef2ea44c933f05f9eaea /python/highlevelil.py
parentd4804f23a48091f03f962d44a7a9c2fd6aeeee81 (diff)
Allow negative indexing of hlil function
Diffstat (limited to 'python/highlevelil.py')
-rw-r--r--python/highlevelil.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/python/highlevelil.py b/python/highlevelil.py
index e815df48..589d6505 100644
--- a/python/highlevelil.py
+++ b/python/highlevelil.py
@@ -804,8 +804,10 @@ class HighLevelILFunction(object):
# for backwards compatibility
if isinstance(i, HighLevelILInstruction):
return i
- if (i < 0) or (i >= len(self)):
+ if i < -len(self) or i >= len(self):
raise IndexError("index out of range")
+ if i < 0:
+ i = len(self) + i
return HighLevelILInstruction(self, core.BNGetHighLevelILIndexForInstruction(self.handle, i), False, i)
def __setitem__(self, i, j):