From 04c4ae864fb0df88b9bc41e85a72062c12540d81 Mon Sep 17 00:00:00 2001 From: Andy Stadler Date: Thu, 27 Jan 2011 16:20:51 -0800 Subject: [PATCH] Prevent NPE in account deletion race condition Bug: 3399372 Change-Id: Ic41fb1292f8cc2e5ceb120e7233229dc4e47f1eb --- src/com/android/email/activity/setup/AccountSettingsXL.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/com/android/email/activity/setup/AccountSettingsXL.java b/src/com/android/email/activity/setup/AccountSettingsXL.java index 4a0595af5..565d27e95 100644 --- a/src/com/android/email/activity/setup/AccountSettingsXL.java +++ b/src/com/android/email/activity/setup/AccountSettingsXL.java @@ -333,7 +333,7 @@ public class AccountSettingsXL extends PreferenceActivity { int headerCount = mAccountListHeaders.length; for (int index = 0; index < headerCount; index++) { Header header = mAccountListHeaders[index]; - if (header.id != HEADER_ID_UNDEFINED) { + if (header != null && header.id != HEADER_ID_UNDEFINED) { if (header.id != mDeletingAccountId) { target.add(header); if (header.id == mRequestedAccountId) { @@ -381,6 +381,9 @@ public class AccountSettingsXL extends PreferenceActivity { * This AsyncTask reads the accounts list and generates the headers. When the headers are * ready, we'll trigger PreferenceActivity to refresh the account list with them. * + * The array generated and stored in mAccountListHeaders may be sparse so any readers should + * check for and skip over null entries, and should not assume array length is # of accounts. + * * TODO: Smaller projection * TODO: Convert to Loader * TODO: Write a test, including operation of deletingAccountId param