From 123d40283e1411dcb5fa5def656ad352c101e5d0 Mon Sep 17 00:00:00 2001 From: Martin Hibdon Date: Wed, 24 Sep 2014 11:25:16 -0700 Subject: [PATCH] Make sure to close a cursor b/17570154 Change-Id: I759a116a14784e92e7fa7eb51755ceda3860550e --- .../com/android/emailcommon/provider/Account.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/emailcommon/src/com/android/emailcommon/provider/Account.java b/emailcommon/src/com/android/emailcommon/provider/Account.java index 513390b69..5a3ab7f3a 100755 --- a/emailcommon/src/com/android/emailcommon/provider/Account.java +++ b/emailcommon/src/com/android/emailcommon/provider/Account.java @@ -225,11 +225,17 @@ public final class Account extends EmailContent implements Parcelable { new String[] {AccountColumns._ID}, AccountColumns.EMAIL_ADDRESS + "=?", new String[] {emailAddress}, null); - if (c == null || !c.moveToFirst()) { - return null; + try { + if (c == null || !c.moveToFirst()) { + return null; + } + final long id = c.getLong(c.getColumnIndex(AccountColumns._ID)); + return restoreAccountWithId(context, id, observer); + } finally { + if (c != null) { + c.close(); + } } - final long id = c.getLong(c.getColumnIndex(AccountColumns._ID)); - return restoreAccountWithId(context, id, observer); } @Override