From 19baa1e9287914df402da0be476f8db5e33e50e9 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 27 Sep 2022 15:14:52 +0200 Subject: [PATCH] Prevent NPE --- .../java/eu/faircode/email/EntityMessage.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/EntityMessage.java b/app/src/main/java/eu/faircode/email/EntityMessage.java index cfc8df6ada..da2f220463 100644 --- a/app/src/main/java/eu/faircode/email/EntityMessage.java +++ b/app/src/main/java/eu/faircode/email/EntityMessage.java @@ -377,19 +377,20 @@ public class EntityMessage implements Serializable { DB db = DB.getInstance(context); boolean notJunk = false; - for (Address sender : from) { - String email = ((InternetAddress) sender).getAddress(); - if (TextUtils.isEmpty(email)) - continue; + if (from != null) + for (Address sender : from) { + String email = ((InternetAddress) sender).getAddress(); + if (TextUtils.isEmpty(email)) + continue; - EntityContact contact = db.contact().getContact(account, EntityContact.TYPE_NO_JUNK, email); - if (contact != null) { - contact.times_contacted++; - contact.last_contacted = new Date().getTime(); - db.contact().updateContact(contact); - notJunk = true; + EntityContact contact = db.contact().getContact(account, EntityContact.TYPE_NO_JUNK, email); + if (contact != null) { + contact.times_contacted++; + contact.last_contacted = new Date().getTime(); + db.contact().updateContact(contact); + notJunk = true; + } } - } return notJunk; }