From 2eecdd1a50676eaae98b75d1d74de697cff39dd7 Mon Sep 17 00:00:00 2001 From: Tony Mantler Date: Mon, 23 Jun 2014 13:38:22 -0700 Subject: [PATCH] Don't leak cursors b/15830514 Change-Id: I91f452fc7c14a076d7f9078ec066215b28ddc3c3 --- src/com/android/email/provider/EmailProvider.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/com/android/email/provider/EmailProvider.java b/src/com/android/email/provider/EmailProvider.java index 5779c6d53..94e4a45ab 100644 --- a/src/com/android/email/provider/EmailProvider.java +++ b/src/com/android/email/provider/EmailProvider.java @@ -4592,9 +4592,14 @@ public class EmailProvider extends ContentProvider final int nameColumn = projectionList.indexOf(UIProvider.FolderColumns.NAME); final int typeColumn = projectionList.indexOf(UIProvider.FolderColumns.TYPE); if (c.moveToFirst()) { - c = getUiFolderCursorRowFromMailboxCursorRow( - new MatrixCursorWithCachedColumns(uiProjection), - uiProjection.length, c, nameColumn, typeColumn); + final Cursor closeThis = c; + try { + c = getUiFolderCursorRowFromMailboxCursorRow( + new MatrixCursorWithCachedColumns(uiProjection), + uiProjection.length, c, nameColumn, typeColumn); + } finally { + closeThis.close(); + } } notifyUri = UIPROVIDER_FOLDER_NOTIFIER.buildUpon().appendPath(mailboxIdString) .build();