Skip to content

Commit 2a8eb64

Browse files
Check result of moveToFirst when querying pragma value
1 parent 622c97f commit 2a8eb64

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

android-database-sqlcipher/src/main/java/net/sqlcipher/database/SQLiteDatabase.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3180,12 +3180,15 @@ private static ArrayList<Pair<String, String>> getAttachedDbs(SQLiteDatabase dbO
31803180
}
31813181

31823182
private Pair<Boolean, String> getResultFromPragma(String command) {
3183+
Pair<Boolean, String> result = new Pair(false, "");
31833184
Cursor cursor = rawQuery(command, new Object[]{});
3184-
if(cursor == null) return new Pair(false, "");
3185-
cursor.moveToFirst();
3186-
String value = cursor.getString(0);
3185+
if(cursor == null) return result;
3186+
if(cursor.moveToFirst()){
3187+
String value = cursor.getString(0);
3188+
result = new Pair(true, value);
3189+
}
31873190
cursor.close();
3188-
return new Pair(true, value);
3191+
return result;
31893192
}
31903193

31913194

0 commit comments

Comments
 (0)