From 8e12dacc81e2b5dadbff59266dac0f84d1e93638 Mon Sep 17 00:00:00 2001 From: Levente Polyak Date: Wed, 22 Feb 2017 20:47:20 +0100 Subject: [PATCH] fix NoneType access if emulator not available through import (#166) This fixes a regression when the emulator support is disabled via setting it to None when the import fails. The access happens when checking if a particular architecture actually supports emulation. Ensure that emulate has the correct value depending on the availability of the import and deactivate it otherwise. The following core can safely rely on the boolean state of the emulate variable. --- pwndbg/disasm/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pwndbg/disasm/__init__.py b/pwndbg/disasm/__init__.py index 41bd86a64..ab63b84be 100644 --- a/pwndbg/disasm/__init__.py +++ b/pwndbg/disasm/__init__.py @@ -172,14 +172,14 @@ def near(address, instructions=1, emulate=False): insns.append(current) # Some architecture aren't emulated yet - if pwndbg.arch.current not in pwndbg.emu.emulator.arch_to_UC: + if not pwndbg.emu or pwndbg.arch.current not in pwndbg.emu.emulator.arch_to_UC: emulate = False # Emulate forward if we are at the current instruction. emu = None # If we hit the current instruction, we can do emulation going forward from there. - if address == pc and pwndbg.emu and emulate: + if address == pc and emulate: emu = pwndbg.emu.emulator.Emulator() # For whatever reason, the first instruction is emulated twice.