From 536908c5d4ba2f919765b41a050269669c800a75 Mon Sep 17 00:00:00 2001 From: Ryan Snyder Date: Tue, 18 Sep 2018 12:25:44 -0400 Subject: python: make BasicBlocks iterate over disassembly lines, not instrs In certain situations Architecture implementations can return different lengths in get_instruction_info and get_instruction_text (e.g. pseudo-instructions). Since BasicBlock's __iter__ method returns disassembly lines, we should advance by the length returned by that callback instead of get_instruction_info, which could be different. --- python/basicblock.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'python/basicblock.py') diff --git a/python/basicblock.py b/python/basicblock.py index c98794cb..8f16f71a 100644 --- a/python/basicblock.py +++ b/python/basicblock.py @@ -304,13 +304,11 @@ class BasicBlock(object): idx = start while idx < end: data = self.view.read(idx, min(self.arch.max_instr_length, end - idx)) - inst_info = self.arch.get_instruction_info(data, idx) inst_text = self.arch.get_instruction_text(data, idx) - - if inst_info is None: + if inst_text[1] == 0: break yield inst_text - idx += inst_info.length + idx += inst_text[1] def mark_recent_use(self): core.BNMarkBasicBlockAsRecentlyUsed(self.handle) -- cgit v1.3.1