Skip to content

Commit

Permalink
Add null checks
Browse files Browse the repository at this point in the history
  • Loading branch information
bpellin committed Oct 7, 2022
1 parent a22a410 commit 8ea8bc7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2018 Brian Pellin.
* Copyright 2013-2022 Brian Pellin.
*
* This file is part of KeePassDroid.
*
Expand Down Expand Up @@ -213,7 +213,11 @@ public void deleteFile(Uri uri, boolean save) {

for (int i = 0; i < databases.size(); i++) {
String entry = databases.get(i);
if (uriName.equals(entry) || fileName.equals(entry)) {
boolean delete;
delete = (uriName != null && uriName.equals((entry)) ||
(fileName != null && fileName.equals(entry)));

if (delete) {
databases.remove(i);
keyfiles.remove(i);
break;
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/keepassdroid/utils/UriUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ public static String getFileName(Uri uri, Context context) {

if (result == null) {
result = uri.getPath();
if (result == null) { return null; }

int cut = result.lastIndexOf('/');
if (cut != -1) {
result = result.substring(cut + 1);
Expand Down

0 comments on commit 8ea8bc7

Please sign in to comment.