From 97acbb7208eb2557694e34da730d38457dec8a7c Mon Sep 17 00:00:00 2001 From: caheckman <48068198+caheckman@users.noreply.github.com> Date: Thu, 7 Dec 2023 00:45:39 +0000 Subject: [PATCH] Check for null pointer when looking up endianess --- Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc index d0623559f9..780d102b5a 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/printc.cc @@ -1997,8 +1997,10 @@ void PrintC::pushPartialSymbol(const Symbol *sym,int4 off,int4 sz, } else if (inslot >= 0) { Datatype *outtype = vn->getHigh()->getType(); - if (castStrategy->isSubpieceCastEndian(outtype,ct,off, - sym->getFirstWholeMap()->getAddr().getSpace()->isBigEndian())) { + AddrSpace *spc = sym->getFirstWholeMap()->getAddr().getSpace(); + if (spc == (AddrSpace *)0) + spc = vn->getSpace(); + if (castStrategy->isSubpieceCastEndian(outtype,ct,off,spc->isBigEndian())) { // Treat truncation as SUBPIECE style cast finalcast = outtype; ct = (Datatype*)0;