From 9151d86e680f8b80ccc2e0bce32a2752c131c317 Mon Sep 17 00:00:00 2001 From: satok Date: Mon, 7 Dec 2009 17:09:57 +0900 Subject: [PATCH] Check null pointer in MessageList BUG: 2299971 --- .../android/email/activity/MessageList.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/com/android/email/activity/MessageList.java b/src/com/android/email/activity/MessageList.java index afc160d45..c4b7d2b51 100644 --- a/src/com/android/email/activity/MessageList.java +++ b/src/com/android/email/activity/MessageList.java @@ -575,15 +575,28 @@ public class MessageList extends ListActivity implements OnItemClickListener, On } EmailContent.Mailbox mailbox = EmailContent.Mailbox.restoreMailboxWithId(this, mailboxId); + if (mailbox == null) { + return -2; + } return mailbox.mAccountKey; } private void onCompose() { - MessageCompose.actionCompose(this, lookupAccountIdFromMailboxId(mMailboxId)); + long accountKey = lookupAccountIdFromMailboxId(mMailboxId); + if (accountKey > -2) { + MessageCompose.actionCompose(this, accountKey); + } else { + finish(); + } } private void onEditAccount() { - AccountSettings.actionSettings(this, lookupAccountIdFromMailboxId(mMailboxId)); + long accountKey = lookupAccountIdFromMailboxId(mMailboxId); + if (accountKey > -2) { + AccountSettings.actionSettings(this, accountKey); + } else { + finish(); + } } private void onDeselectAll() { @@ -638,8 +651,12 @@ public class MessageList extends ListActivity implements OnItemClickListener, On c.close(); } } else { - long accountId = lookupAccountIdFromMailboxId(mMailboxId); - mController.sendPendingMessages(accountId, mControllerCallback); + long accountKey = lookupAccountIdFromMailboxId(mMailboxId); + if (accountKey > -2) { + mController.sendPendingMessages(accountKey, mControllerCallback); + } else { + finish(); + } } }