From 33c0bf9e317c924958de25c8aae65e3860a3c8a3 Mon Sep 17 00:00:00 2001 From: cketti Date: Fri, 6 May 2011 20:02:55 +0200 Subject: [PATCH] Avoid NullPointerException for messages with html_content = NULL in DB Fixes issue 3302 --- src/com/fsck/k9/mail/store/LocalStore.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/com/fsck/k9/mail/store/LocalStore.java b/src/com/fsck/k9/mail/store/LocalStore.java index b2ed1069f..ad487af06 100644 --- a/src/com/fsck/k9/mail/store/LocalStore.java +++ b/src/com/fsck/k9/mail/store/LocalStore.java @@ -2425,16 +2425,18 @@ public class LocalStore extends Store implements Serializable { { Long.toString(messageId) }, null, null, null); try { if (cursor.moveToNext()) { - String new_html; + String htmlContent = cursor.getString(0); - new_html = cursor.getString(0); - new_html = new_html.replaceAll(Pattern.quote("cid:" + contentId), - contentUri.toString()); + if (htmlContent != null) { + String newHtmlContent = htmlContent.replaceAll( + Pattern.quote("cid:" + contentId), + contentUri.toString()); - ContentValues cv = new ContentValues(); - cv.put("html_content", new_html); - db.update("messages", cv, "id = ?", new String[] - { Long.toString(messageId) }); + ContentValues cv = new ContentValues(); + cv.put("html_content", newHtmlContent); + db.update("messages", cv, "id = ?", new String[] + { Long.toString(messageId) }); + } } } finally { if (cursor != null) {