From aff0561691a0f62b4db00df0fdd62946a13fa918 Mon Sep 17 00:00:00 2001 From: Ryan Kurtz Date: Fri, 23 May 2025 06:07:58 -0400 Subject: [PATCH] GP-0: Fixing NPE in Batch Importer (#Closes #8191) --- .../java/ghidra/formats/gfilesystem/GFileSystem.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Ghidra/Features/Base/src/main/java/ghidra/formats/gfilesystem/GFileSystem.java b/Ghidra/Features/Base/src/main/java/ghidra/formats/gfilesystem/GFileSystem.java index cb750ce60e..50125e7b2a 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/formats/gfilesystem/GFileSystem.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/formats/gfilesystem/GFileSystem.java @@ -266,12 +266,13 @@ public interface GFileSystem extends Closeable, Iterable, ExtensionPoint /** * Gets an {@link Iterator} over this {@link GFileSystem}'s {@link GFile files}. * - * @param dir The {@link GFile directory} to start iterating at in this {@link GFileSystem} + * @param dir The {@link GFile directory} to start iterating at in this {@link GFileSystem}. If + * {@code null}, iteration will start at the root of the {@link GFileSystem}. * @throws UncheckedIOException if {@code dir} is not a directory * @return An {@link Iterable} over this {@link GFileSystem}'s {@link GFile files}. */ default Iterable files(GFile dir) throws UncheckedIOException { - return () -> new GFileSystemIterator(dir); + return () -> new GFileSystemIterator(Objects.requireNonNullElse(dir, getRootDir())); } /** @@ -287,14 +288,16 @@ public interface GFileSystem extends Closeable, Iterable, ExtensionPoint /** * Gets an {@link Iterator} over this {@link GFileSystem}'s {@link GFile files}. * - * @param dir The {@link GFile directory} to start iterating at in this {@link GFileSystem} + * @param dir The {@link GFile directory} to start iterating at in this {@link GFileSystem}. If + * {@code null}, iteration will start at the root of the {@link GFileSystem}. * @param fileFilter A filter to apply to the {@link GFile files} iterated over * @throws UncheckedIOException if {@code dir} is not a directory * @return An {@link Iterable} over this {@link GFileSystem}'s {@link GFile files}. */ default Iterable files(GFile dir, Predicate fileFilter) throws UncheckedIOException { - return () -> new GFileSystemIterator(dir, fileFilter); + return () -> new GFileSystemIterator(Objects.requireNonNullElse(dir, getRootDir()), + fileFilter); } @Override