Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fce5890a authored by Jeff Brown's avatar Jeff Brown
Browse files

Fix NPE in deleteDatabase().

If the directory containing the database does not exist then
listFiles() will return null.  Tolerate this situation instead
of crashing.

Bug: 12600784
Change-Id: I5d83a867a5e8478f50887e5798b42c5f6859b77c
parent 8aca9e33
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -738,16 +738,18 @@ public final class SQLiteDatabase extends SQLiteClosable {
        File dir = file.getParentFile();
        if (dir != null) {
            final String prefix = file.getName() + "-mj";
            final FileFilter filter = new FileFilter() {
            File[] files = dir.listFiles(new FileFilter() {
                @Override
                public boolean accept(File candidate) {
                    return candidate.getName().startsWith(prefix);
                }
            };
            for (File masterJournal : dir.listFiles(filter)) {
            });
            if (files != null) {
                for (File masterJournal : files) {
                    deleted |= masterJournal.delete();
                }
            }
        }
        return deleted;
    }