-
Notifications
You must be signed in to change notification settings - Fork 247
Closed
Labels
Description
Dear developers,
I found two potential leaks of database cursor in your code.
(1) In the method private void manageNewStoragePath(SQLiteDatabase db) of DatabaseHelper class at line 203 and 234:
If the cursor is empty (no rows), it will not be closed as in the code only when moveToFirst() returns true (non-empty cursors), the cursor.close() statement at line 234 will execute.
(2) In the public static File getTrackDirFromDB(ContentResolver cr, long trackId) of DataHelper class at line 341:
if (c != null && c.getCount() != 0) {
c.moveToFirst();
@SuppressWarnings("deprecation")
String trackPath = c.getString(c.getColumnIndex(Schema.COL_DIR));
if (trackPath != null) {
trackDir = new File(trackPath);
}
c.close();
c = null;
}
In the above code, if the cursor is empty (getCount() == 0), the cursor will be not closed.