1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-22 10:37:59 +01:00

[address] Fix NPE in MultipleRecipientManager

The arguments 'to', 'cc, and 'bcc' may be null, hence ensure that they
are non-null when calling e.g. size() on them.

Fixes SMACK-907

Fixes: df96c57093 ("[address] Get rid of PacketCopy workaround")
This commit is contained in:
Florian Schmaus 2021-06-03 19:10:07 +02:00
parent 4eb5869860
commit 26e6efa767

View file

@ -19,6 +19,7 @@ package org.jivesoftware.smackx.address;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.jivesoftware.smack.SmackException.FeatureNotSupportedException;
@ -228,18 +229,16 @@ public class MultipleRecipientManager {
throw new AssertionError();
}
if (to == null) to = Collections.emptyList();
if (cc == null) cc = Collections.emptyList();
if (bcc == null) bcc = Collections.emptyList();
final int numRecipients = to.size() + cc.size() + bcc.size();
final List<Jid> recipients = new ArrayList<>(numRecipients);
if (to != null) {
recipients.addAll(to);
}
if (cc != null) {
recipients.addAll(cc);
}
if (bcc != null) {
recipients.addAll(bcc);
}
recipients.addAll(to);
recipients.addAll(cc);
recipients.addAll(bcc);
final List<Stanza> stanzasToSend = new ArrayList<>(numRecipients);
for (Jid recipient : recipients) {