From fd34b2abb50496d925b416f62938540086340fc0 Mon Sep 17 00:00:00 2001 From: Disconnect3d Date: Sun, 13 Jan 2019 01:24:50 +0100 Subject: [PATCH] Fix #587 - bug in enhance_next (#588) --- pwndbg/disasm/arch.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pwndbg/disasm/arch.py b/pwndbg/disasm/arch.py index 47fd4ae06..3fa4a9782 100644 --- a/pwndbg/disasm/arch.py +++ b/pwndbg/disasm/arch.py @@ -8,6 +8,7 @@ from __future__ import unicode_literals import collections import capstone +import gdb from capstone import * import pwndbg.memoize @@ -147,7 +148,12 @@ class DisassemblyAssistant(object): # self.memory may return none, so we need to check it here again if addr is not None: - addr = int(pwndbg.memory.poi(pwndbg.typeinfo.ppvoid, addr)) + try: + # fails with gdb.MemoryError if the dereferenced address + # doesn't belong to any of process memory maps + addr = int(pwndbg.memory.poi(pwndbg.typeinfo.ppvoid, addr)) + except gdb.MemoryError: + return None if op.type == CS_OP_REG: addr = self.register(instruction, op) @@ -243,6 +249,9 @@ class DisassemblyAssistant(object): return None # raise NotImplementedError def dump(self, instruction): + """ + Debug-only method. + """ ins = instruction rv = [] rv.append('%s %s' % (ins.mnemonic, ins.op_str))