mirror of https://github.com/pwndbg/pwndbg
Add gdb.MemoryError check to get_heap() (#1145)
Call fetch_lazy() on the gdb.Value acquired in get_heap() and wrap it in a try/except block. Return None if gdb.MemoryError is raised. Let get_arena_for_chunk() handle None returned by get_heap(). Fixes #1142
This commit is contained in:
parent
dea9a691d4
commit
8dae55490b
|
@ -307,7 +307,8 @@ class Heap(pwndbg.heap.heap.BaseHeap):
|
|||
chunk = pwndbg.commands.heap.read_chunk(addr)
|
||||
_, _, nm = self.chunk_flags(chunk["size"])
|
||||
if nm:
|
||||
r = self.get_arena(arena_addr=self.get_heap(addr)["ar_ptr"])
|
||||
h = self.get_heap(addr)
|
||||
r = self.get_arena(h["ar_ptr"]) if h else None
|
||||
else:
|
||||
r = self.main_arena
|
||||
return r
|
||||
|
@ -634,7 +635,13 @@ class DebugSymsHeap(Heap):
|
|||
|
||||
def get_heap(self, addr):
|
||||
"""Find & read the heap_info struct belonging to the chunk at 'addr'."""
|
||||
return pwndbg.gdblib.memory.poi(self.heap_info, heap_for_ptr(addr))
|
||||
try:
|
||||
r = pwndbg.gdblib.memory.poi(self.heap_info, heap_for_ptr(addr))
|
||||
r.fetch_lazy()
|
||||
except gdb.MemoryError:
|
||||
r = None
|
||||
|
||||
return r
|
||||
|
||||
def get_arena(self, arena_addr=None):
|
||||
"""Read a malloc_state struct from the specified address, default to
|
||||
|
|
Loading…
Reference in New Issue