From 924f84b3c32d57127aecacca4920db3e62f56f9d Mon Sep 17 00:00:00 2001 From: Ryan Kurtz Date: Tue, 8 Nov 2022 09:28:46 -0500 Subject: [PATCH] GP-2802: Fixed an issue that prevented some Mach-O binaries from being imported if there were unexpected issues while creating the Program Tree. --- .../ghidra/app/util/opinion/MachoProgramBuilder.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoProgramBuilder.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoProgramBuilder.java index e6bbe16480..4b84f81733 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoProgramBuilder.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoProgramBuilder.java @@ -427,8 +427,18 @@ public class MachoProgramBuilder { break; } } + if (segmentFragment == null) { + log.appendMsg("Could not find/fixup segment in Program Tree: " + segmentName); + continue; + } ProgramModule segmentModule = rootModule.createModule(segmentName); - segmentModule.reparent(noSectionsName, rootModule); + try { + segmentModule.reparent(noSectionsName, rootModule); + } + catch (NotFoundException e) { + log.appendException(e); + continue; + } // Add the sections, which will remove overlapped ranges from the segment fragment for (Section section : segment.getSections()) {