From 64ca9a66cf5b8d1a07cae2975fcc4b471650efd8 Mon Sep 17 00:00:00 2001 From: Bet4 <0xbet4@gmail.com> Date: Sun, 8 Mar 2020 21:11:04 +0800 Subject: [PATCH] Fix decompile error (#716) --- ida_script.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ida_script.py b/ida_script.py index 8f0c1c5a..706ae144 100644 --- a/ida_script.py +++ b/ida_script.py @@ -119,7 +119,7 @@ def get_decompile_coord_by_ea(cfunc, addr): item = cfunc.body.find_closest_addr(addr) y_holder = idaapi.int_pointer() if not cfunc.find_item_coords(item, None, y_holder): - return cfunc + return None y = y_holder.value() else: 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) if ret and pitem.it: lnmap[pitem.it.ea] = i - y = -1 + y = None closest_ea = BADADDR for ea,line in lnmap.items(): if closest_ea == BADADDR or abs(closest_ea - addr) > abs(ea - addr): closest_ea = ea y = lnmap[ea] - + return y @@ -144,8 +144,9 @@ def decompile_context(addr, context_lines): cfunc = decompile(addr) if cfunc is None: return None - y = get_decompile_coord_by_ea(cfunc, addr) + if y is None: + return cfunc lines = cfunc.get_pseudocode() retlines = [] for lnnum in range(max(0, y - context_lines), min(len(lines), y + context_lines)):