1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-24 02:12:15 -05: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 { String sortOrder) throws Exception {
mSemaphore.acquire(); mSemaphore.acquire();
final Cursor cursor; Cursor cursor = null;
cursor = mDelegate.query(uri, projection, selection, selectionArgs, sortOrder); try {
cursor = mDelegate.query(uri, projection, selection, selectionArgs, sortOrder);
} finally {
if (cursor == null) {
mSemaphore.release();
}
}
/* Android content resolvers can only process CrossProcessCursor instances */ /* Android content resolvers can only process CrossProcessCursor instances */
if (!(cursor instanceof CrossProcessCursor)) { if (!(cursor instanceof CrossProcessCursor)) {
Log.w(K9.LOG_TAG, "Unsupported cursor, returning null: " + cursor); Log.w(K9.LOG_TAG, "Unsupported cursor, returning null: " + cursor);
mSemaphore.release();
return null; return null;
} }