From d9ff5b00b7e5b778acf196b29182b5784377718f Mon Sep 17 00:00:00 2001 From: Benedikt Constantin Radtke Date: Sat, 3 Dec 2016 22:38:22 +0100 Subject: [PATCH] fix NPE in PushGroupUpdateJob Fixes #5919 Closes #5921 // FREEBIE --- .../securesms/jobs/PushGroupUpdateJob.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/org/thoughtcrime/securesms/jobs/PushGroupUpdateJob.java b/src/org/thoughtcrime/securesms/jobs/PushGroupUpdateJob.java index 607a4c2a9b..b6b32b7724 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushGroupUpdateJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushGroupUpdateJob.java @@ -57,17 +57,21 @@ public class PushGroupUpdateJob extends ContextJob implements InjectableType { SignalServiceMessageSender messageSender = messageSenderFactory.create(); GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context); GroupRecord record = groupDatabase.getGroup(groupId); + SignalServiceAttachment avatar = null; if (record == null) { Log.w(TAG, "No information for group record info request: " + new String(groupId)); return; } - SignalServiceAttachment avatar = SignalServiceAttachmentStream.newStreamBuilder() - .withContentType("image/jpeg") - .withStream(new ByteArrayInputStream(record.getAvatar())) - .withLength(record.getAvatar().length) - .build(); + if (record.getAvatar() != null) { + avatar = SignalServiceAttachmentStream.newStreamBuilder() + .withContentType("image/jpeg") + .withStream(new ByteArrayInputStream(record.getAvatar())) + .withLength(record.getAvatar().length) + .build(); + } + SignalServiceGroup groupContext = SignalServiceGroup.newBuilder(Type.UPDATE) .withAvatar(avatar)