Fix decompile error (#716)

This commit is contained in:
Bet4 2020-03-08 21:11:04 +08:00 committed by GitHub
parent c46417f709
commit 64ca9a66cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -119,7 +119,7 @@ def get_decompile_coord_by_ea(cfunc, addr):
item = cfunc.body.find_closest_addr(addr) item = cfunc.body.find_closest_addr(addr)
y_holder = idaapi.int_pointer() y_holder = idaapi.int_pointer()
if not cfunc.find_item_coords(item, None, y_holder): if not cfunc.find_item_coords(item, None, y_holder):
return cfunc return None
y = y_holder.value() y = y_holder.value()
else: else:
lnmap = {} lnmap = {}
@ -130,13 +130,13 @@ def get_decompile_coord_by_ea(cfunc, addr):
ret = cfunc.get_line_item(line.line, 0, True, phead, pitem, ptail) ret = cfunc.get_line_item(line.line, 0, True, phead, pitem, ptail)
if ret and pitem.it: if ret and pitem.it:
lnmap[pitem.it.ea] = i lnmap[pitem.it.ea] = i
y = -1 y = None
closest_ea = BADADDR closest_ea = BADADDR
for ea,line in lnmap.items(): for ea,line in lnmap.items():
if closest_ea == BADADDR or abs(closest_ea - addr) > abs(ea - addr): if closest_ea == BADADDR or abs(closest_ea - addr) > abs(ea - addr):
closest_ea = ea closest_ea = ea
y = lnmap[ea] y = lnmap[ea]
return y return y
@ -144,8 +144,9 @@ def decompile_context(addr, context_lines):
cfunc = decompile(addr) cfunc = decompile(addr)
if cfunc is None: if cfunc is None:
return None return None
y = get_decompile_coord_by_ea(cfunc, addr) y = get_decompile_coord_by_ea(cfunc, addr)
if y is None:
return cfunc
lines = cfunc.get_pseudocode() lines = cfunc.get_pseudocode()
retlines = [] retlines = []
for lnnum in range(max(0, y - context_lines), min(len(lines), y + context_lines)): for lnnum in range(max(0, y - context_lines), min(len(lines), y + context_lines)):