fix a potential NPE

This commit is contained in:
zeapo 2017-10-30 22:49:25 +01:00
parent b6cb649f7c
commit 57358a86ac
2 changed files with 2 additions and 3 deletions

View file

@ -377,8 +377,7 @@ public class AutofillService extends AccessibilityService {
} }
private ArrayList<File> searchPasswords(File path, String appName) { private ArrayList<File> searchPasswords(File path, String appName) {
ArrayList<File> passList ArrayList<File> passList = PasswordRepository.getFilesList(path);
= PasswordRepository.getFilesList(path);
if (passList.size() == 0) return new ArrayList<>(); if (passList.size() == 0) return new ArrayList<>();

View file

@ -166,7 +166,7 @@ public class PasswordRepository {
* @return the list of gpg files in that directory * @return the list of gpg files in that directory
*/ */
public static ArrayList<File> getFilesList(File path) { public static ArrayList<File> getFilesList(File path) {
if (!path.exists()) return new ArrayList<>(); if (path == null || !path.exists()) return new ArrayList<>();
Log.d("REPO", "current path: " + path.getPath()); Log.d("REPO", "current path: " + path.getPath());
List<File> directories = Arrays.asList(path.listFiles((FileFilter) FileFilterUtils.directoryFileFilter())); List<File> directories = Arrays.asList(path.listFiles((FileFilter) FileFilterUtils.directoryFileFilter()));