From 57358a86accb9424144314394212951570fc2085 Mon Sep 17 00:00:00 2001 From: zeapo Date: Mon, 30 Oct 2017 22:49:25 +0100 Subject: [PATCH] fix a potential NPE --- .../main/java/com/zeapo/pwdstore/autofill/AutofillService.java | 3 +-- .../main/java/com/zeapo/pwdstore/utils/PasswordRepository.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java index 16bf4547..9578df0d 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.java @@ -377,8 +377,7 @@ public class AutofillService extends AccessibilityService { } private ArrayList searchPasswords(File path, String appName) { - ArrayList passList - = PasswordRepository.getFilesList(path); + ArrayList passList = PasswordRepository.getFilesList(path); if (passList.size() == 0) return new ArrayList<>(); diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java index 990aec39..e232b8a0 100644 --- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java +++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java @@ -166,7 +166,7 @@ public class PasswordRepository { * @return the list of gpg files in that directory */ public static ArrayList getFilesList(File path) { - if (!path.exists()) return new ArrayList<>(); + if (path == null || !path.exists()) return new ArrayList<>(); Log.d("REPO", "current path: " + path.getPath()); List directories = Arrays.asList(path.listFiles((FileFilter) FileFilterUtils.directoryFileFilter()));