diff --git a/src/com/fsck/k9/provider/MessageProvider.java b/src/com/fsck/k9/provider/MessageProvider.java index 04f0f6e20..80c5b0be7 100644 --- a/src/com/fsck/k9/provider/MessageProvider.java +++ b/src/com/fsck/k9/provider/MessageProvider.java @@ -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; }