about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorFlorent <florent.monjalet@gmail.com>2015-10-29 13:02:14 +0100
committerFlorent <florent.monjalet@gmail.com>2015-10-29 13:02:14 +0100
commit967be0c4e0f8d32f6bf3e8aa9f85d0abc9ab95da (patch)
tree2c326b1e677613800261ac58bf69e8935b271899
parent996b4ae4464c0b0aabadaacdea775b217ed5ed32 (diff)
parent976337d3aaada7adb2e1f2788c8558a024652b2d (diff)
downloadmiasm-967be0c4e0f8d32f6bf3e8aa9f85d0abc9ab95da.tar.gz
miasm-967be0c4e0f8d32f6bf3e8aa9f85d0abc9ab95da.zip
Merge pull request #249 from serpilliere/fix_get_subcall
Core/asmbloc: Fix get_subcall_instr
-rw-r--r--miasm2/core/asmbloc.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/miasm2/core/asmbloc.py b/miasm2/core/asmbloc.py
index 31e4bdd7..9f67747c 100644
--- a/miasm2/core/asmbloc.py
+++ b/miasm2/core/asmbloc.py
@@ -203,10 +203,14 @@ class asm_bloc(object):
     def get_subcall_instr(self):
         if not self.lines:
             return None
-        for i in xrange(-1, -1 - self.lines[0].delayslot - 1, -1):
+        delayslot = self.lines[0].delayslot
+        end_index = len(self.lines) - 1
+        ds_max_index = max(end_index - delayslot, 0)
+        for i in xrange(end_index, ds_max_index - 1, -1):
             l = self.lines[i]
             if l.is_subcall():
                 return l
+        return None
 
     def get_next(self):
         for x in self.bto: