From e55eb9ba8ea912b00ba35e12c7ca1b31240ba143 Mon Sep 17 00:00:00 2001 From: link2xt Date: Mon, 27 Mar 2023 10:43:48 +0000 Subject: [PATCH] Avoid NullPointerException in setGenericInfoRecord --- .../securesms/ConversationUpdateItem.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/org/thoughtcrime/securesms/ConversationUpdateItem.java b/src/org/thoughtcrime/securesms/ConversationUpdateItem.java index 1ada245a8..99fea57fb 100644 --- a/src/org/thoughtcrime/securesms/ConversationUpdateItem.java +++ b/src/org/thoughtcrime/securesms/ConversationUpdateItem.java @@ -90,15 +90,20 @@ public class ConversationUpdateItem extends BaseConversationItem private void setGenericInfoRecord(DcMsg messageRecord) { if (messageRecord.getInfoType() == DcMsg.DC_INFO_WEBXDC_INFO_MESSAGE) { DcMsg parentMsg = messageRecord.getParent(); - JSONObject info = parentMsg.getWebxdcInfo(); - byte[] blob = parentMsg.getWebxdcBlob(JsonUtils.optString(info, "icon")); - if (blob != null) { - ByteArrayInputStream is = new ByteArrayInputStream(blob); - Drawable drawable = Drawable.createFromStream(is, "icon"); - appIcon.setImageDrawable(drawable); - appIcon.setVisibility(VISIBLE); - } else { - appIcon.setVisibility(GONE); + + // It is possible that we only received an update without the webxdc itself. + // In this case parentMsg is null and we display update message without the icon. + if (parentMsg != null) { + JSONObject info = parentMsg.getWebxdcInfo(); + byte[] blob = parentMsg.getWebxdcBlob(JsonUtils.optString(info, "icon")); + if (blob != null) { + ByteArrayInputStream is = new ByteArrayInputStream(blob); + Drawable drawable = Drawable.createFromStream(is, "icon"); + appIcon.setImageDrawable(drawable); + appIcon.setVisibility(VISIBLE); + } else { + appIcon.setVisibility(GONE); + } } } else { appIcon.setVisibility(GONE);