From 6354fdce7aeb592619e2348e5651a56a99a23e93 Mon Sep 17 00:00:00 2001 From: anthraxx Date: Tue, 30 Mar 2021 22:22:40 +0200 Subject: [PATCH] fix(ghidra): avoid crash if we try to decompile a faulty addr/func This may happen if either something goes wrong during the command or if the passed addr/func for custom decompilation is simply faulty. --- pwndbg/ghidra.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pwndbg/ghidra.py b/pwndbg/ghidra.py index d11bc16e6..064aeb3b0 100644 --- a/pwndbg/ghidra.py +++ b/pwndbg/ghidra.py @@ -31,6 +31,10 @@ def decompile(func=None): except: func = "main" src = r2.cmdj("pdgj @" + func) + # Early exit if decompile command failed horribly, like unknown addr/func + if not src: + return [] + source = src.get("code", "") curline = None try: