1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-08-13 17:03:48 -04:00

Make sure semaphore in MessageProvider is released in case of an error

Patch provided by teslacoil
This commit is contained in:
cketti 2013-02-02 04:25:39 +01:00
parent 3171ee969f
commit 57e55734c4

View File

@ -840,12 +840,19 @@ public class MessageProvider extends ContentProvider {
String sortOrder) throws Exception {
mSemaphore.acquire();
final Cursor cursor;
cursor = mDelegate.query(uri, projection, selection, selectionArgs, sortOrder);
Cursor cursor = null;
try {
cursor = mDelegate.query(uri, projection, selection, selectionArgs, sortOrder);
} finally {
if (cursor == null) {
mSemaphore.release();
}
}
/* Android content resolvers can only process CrossProcessCursor instances */
if (!(cursor instanceof CrossProcessCursor)) {
Log.w(K9.LOG_TAG, "Unsupported cursor, returning null: " + cursor);
mSemaphore.release();
return null;
}