From 3285fb3cfdb209257ed5fb8f36a4d98c67b0d53e Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Tue, 18 Oct 2011 13:27:30 -0700 Subject: [PATCH] Prevent NPE with badly-timed account deletion Bug: 5473621 Change-Id: I0956540de0de172bc3519a301598e197b449b9a8 --- src/com/android/email/MessagingController.java | 4 ++++ src/com/android/email/mail/Store.java | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/com/android/email/MessagingController.java b/src/com/android/email/MessagingController.java index be1aa8d72..6a0f1e1d8 100644 --- a/src/com/android/email/MessagingController.java +++ b/src/com/android/email/MessagingController.java @@ -364,6 +364,8 @@ public class MessagingController implements Runnable { // Select generic sync or store-specific sync SyncResults results = synchronizeMailboxGeneric(account, folder); + // The account might have been deleted + if (results == null) return; mListeners.synchronizeMailboxFinished(account.mId, folder.mId, results.mTotalMessages, results.mAddedMessages.size(), @@ -771,6 +773,8 @@ public class MessagingController implements Runnable { // 2. Open the remote folder and create the remote folder if necessary Store remoteStore = Store.getInstance(account, mContext); + // The account might have been deleted + if (remoteStore == null) return null; Folder remoteFolder = remoteStore.getFolder(mailbox.mServerId); /* diff --git a/src/com/android/email/mail/Store.java b/src/com/android/email/mail/Store.java index 27c9492b8..bdf90391f 100644 --- a/src/com/android/email/mail/Store.java +++ b/src/com/android/email/mail/Store.java @@ -88,6 +88,8 @@ public abstract class Store { public synchronized static Store getInstance(Account account, Context context) throws MessagingException { HostAuth hostAuth = account.getOrCreateHostAuthRecv(context); + // An existing account might have been deleted + if (hostAuth == null) return null; Store store = sStores.get(hostAuth); if (store == null) { Context appContext = context.getApplicationContext();