guardianproject / ChatSecureAndroid

This project has ended, but ChatSecure iOS continues. For Android, please use Conversations or Zom instead
https://chatsecure.org/blog/chatsecure-conversations-zom/
Apache License 2.0
1.07k stars 521 forks source link

resource leak: database cursor not closed #755

Closed andrew659 closed 7 years ago

andrew659 commented 7 years ago

Dear developers,

I found one potential leak of database cursor in your code.

In the getRealPathFromURI() method of the NewChatActivity class starting from line 1376:

Cursor cursor = managedQuery(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);

The cursor is not closed. Is it a bug? Thanks.

andrew659 commented 7 years ago

I realized that the cursor is an automatically managed one. So the code should be fine.