FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Ensured that library metadata methods close their handles. · drydart/flutter_sqlcipher@b3eed6d · GitHub

Repository navigation

Commit b3eed6d

Browse files
committed
Ensured that library metadata methods close their handles.
1 parent af6b76f commit b3eed6d

2 files changed

Lines changed: 26 additions & 6 deletions

File tree

‎android/src/main/java/com/github/drydart/flutter_sqlcipher/SQLCipherMethodHandler.java‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,19 @@ class SQLCipherMethodHandler implements MethodCallHandler {
3131

3232
case "getVersion": {
3333
final SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(":memory:", (String)null, null);
34-
final Cursor cursor = db.rawQuery("PRAGMA cipher_version", null);
35-
cursor.moveToNext();
36-
result.success(cursor.getString(0));
34+
try {
35+
final Cursor cursor = db.rawQuery("PRAGMA cipher_version", null);
36+
try {
37+
cursor.moveToNext();
38+
result.success(cursor.getString(0));
39+
}
40+
finally {
41+
cursor.close();
42+
}
43+
}
44+
finally {
45+
db.close();
46+
}
3747
break;
3848
}
3949

‎android/src/main/java/com/github/drydart/flutter_sqlcipher/SQLiteMethodHandler.java‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,19 @@ class SQLiteMethodHandler implements MethodCallHandler {
3131

3232
case "getVersion": {
3333
final SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(":memory:", (String)null, null);
34-
final Cursor cursor = db.rawQuery("SELECT sqlite_version()", null);
35-
cursor.moveToNext();
36-
result.success(cursor.getString(0));
34+
try {
35+
final Cursor cursor = db.rawQuery("SELECT sqlite_version()", null);
36+
try {
37+
cursor.moveToNext();
38+
result.success(cursor.getString(0));
39+
}
40+
finally {
41+
cursor.close();
42+
}
43+
}
44+
finally {
45+
db.close();
46+
}
3747
break;
3848
}
3949

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL