Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-3445: Fixed an IllegalStateException that could occur if both "Load Local Libraries From Disk" and "Load System Libraries From Disk" options are used during import, and the same library is found in both local and system directories

Ryan Kurtz0d3d65de235e
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/AbstractLibrarySupportLoader.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/AbstractLibrarySupportLoader.java
index be57daae40..7ede49de11 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/AbstractLibrarySupportLoader.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/AbstractLibrarySupportLoader.java
@@ -507,6 +507,7 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader
// options turned off (if shouldSearchAllPaths() is overridden to return true).
// In this case, we still want to process those libraries, but we
// do not want to save them, so they can be released.
+ boolean loadedLocal = false;
if (!localSearchPaths.isEmpty()) {
Loaded<Program> loadedLibrary = loadLibraryFromSearchPaths(
libraryName, provider, localSearchPaths, libraryDestFolderPath,
@@ -514,13 +515,14 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader
if (loadedLibrary != null) {
if (loadLocalLibraries) {
loadedPrograms.add(loadedLibrary);
+ loadedLocal = true;
}
else {
loadedLibrary.release(consumer);
}
}
}
- if (!systemSearchPaths.isEmpty()) {
+ if (!loadedLocal && !systemSearchPaths.isEmpty()) {
Loaded<Program> loadedLibrary = loadLibraryFromSearchPaths(
libraryName, provider, systemSearchPaths, libraryDestFolderPath,
unprocessed, depth, desiredLoadSpec, options, log, consumer, monitor);