From edd1c9ac7e92da3ca5459f4c7c3154b98ff68eac Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Wed, 9 Mar 2011 16:44:44 -0800 Subject: [PATCH] Fix NPE when trying to open attachments The attachment info may be null when we attempt to mark them for downloading. Add a null-check before we try to dereference the info structure. bug 4053184 Change-Id: I831e3abd100664c92f7af585014a03250e40ff64 --- src/com/android/email/Controller.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/com/android/email/Controller.java b/src/com/android/email/Controller.java index 2d13e4200..a7b77c5b6 100644 --- a/src/com/android/email/Controller.java +++ b/src/com/android/email/Controller.java @@ -868,8 +868,11 @@ public class Controller { */ public void loadAttachment(final long attachmentId, final long messageId, final long accountId) { - Attachment attachInfo = Attachment.restoreAttachmentWithId(mProviderContext, attachmentId); + if (attachInfo == null) { + return; + } + if (Utility.attachmentExists(mProviderContext, attachInfo)) { // The attachment has already been downloaded, so we will just "pretend" to download it // This presumably is for POP3 messages