fix NPE in PushGroupUpdateJob

Fixes #5919
Closes #5921
// FREEBIE
This commit is contained in:
Benedikt Constantin Radtke 2016-12-03 22:38:22 +01:00 committed by Moxie Marlinspike
parent 5d341e175d
commit d9ff5b00b7

View File

@ -57,17 +57,21 @@ public class PushGroupUpdateJob extends ContextJob implements InjectableType {
SignalServiceMessageSender messageSender = messageSenderFactory.create(); SignalServiceMessageSender messageSender = messageSenderFactory.create();
GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context); GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context);
GroupRecord record = groupDatabase.getGroup(groupId); GroupRecord record = groupDatabase.getGroup(groupId);
SignalServiceAttachment avatar = null;
if (record == null) { if (record == null) {
Log.w(TAG, "No information for group record info request: " + new String(groupId)); Log.w(TAG, "No information for group record info request: " + new String(groupId));
return; return;
} }
SignalServiceAttachment avatar = SignalServiceAttachmentStream.newStreamBuilder() if (record.getAvatar() != null) {
.withContentType("image/jpeg") avatar = SignalServiceAttachmentStream.newStreamBuilder()
.withStream(new ByteArrayInputStream(record.getAvatar())) .withContentType("image/jpeg")
.withLength(record.getAvatar().length) .withStream(new ByteArrayInputStream(record.getAvatar()))
.build(); .withLength(record.getAvatar().length)
.build();
}
SignalServiceGroup groupContext = SignalServiceGroup.newBuilder(Type.UPDATE) SignalServiceGroup groupContext = SignalServiceGroup.newBuilder(Type.UPDATE)
.withAvatar(avatar) .withAvatar(avatar)