1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 14:22:05 +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.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.List; import java.util.List;
import org.jivesoftware.smack.SmackException.FeatureNotSupportedException; import org.jivesoftware.smack.SmackException.FeatureNotSupportedException;
@ -228,18 +229,16 @@ public class MultipleRecipientManager {
throw new AssertionError(); 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 int numRecipients = to.size() + cc.size() + bcc.size();
final List<Jid> recipients = new ArrayList<>(numRecipients); final List<Jid> recipients = new ArrayList<>(numRecipients);
if (to != null) { recipients.addAll(to);
recipients.addAll(to); recipients.addAll(cc);
} recipients.addAll(bcc);
if (cc != null) {
recipients.addAll(cc);
}
if (bcc != null) {
recipients.addAll(bcc);
}
final List<Stanza> stanzasToSend = new ArrayList<>(numRecipients); final List<Stanza> stanzasToSend = new ArrayList<>(numRecipients);
for (Jid recipient : recipients) { for (Jid recipient : recipients) {