From feb8eefcc4d0825568d158199c490ff4998c9ad5 Mon Sep 17 00:00:00 2001 From: Mohamed Zenadi Date: Mon, 3 Aug 2015 00:01:24 +0200 Subject: fix potential NPE --- app/src/main/java/com/zeapo/pwdstore/PasswordStore.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index b72fa1ca..4602cf59 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -449,9 +449,13 @@ public class PasswordStore extends AppCompatActivity { case CLONE_REPO_BUTTON: // duplicate code if (settings.getBoolean("git_external", false) && settings.getString("git_external_repo", null) != null) { - File dir = new File(settings.getString("git_external_repo", null)); + String externalRepoPath = settings.getString("git_external_repo", null); + File dir = externalRepoPath != null ? new File(externalRepoPath) : null; - if (dir.exists() && dir.isDirectory() && !FileUtils.listFiles(dir, null, true).isEmpty() && + if (dir != null && + dir.exists() && + dir.isDirectory() && + !FileUtils.listFiles(dir, null, true).isEmpty() && !PasswordRepository.getPasswords(dir).isEmpty()) { PasswordRepository.closeRepository(); checkLocalRepository(); -- cgit v1.2.3