prevent crash when counterpart in message was null

This commit is contained in:
Daniel Gultsch 2019-11-10 11:30:31 +01:00
parent 7b7719db8c
commit 97745bdfbe

View file

@ -307,9 +307,13 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
synchronized (this.messages) { synchronized (this.messages) {
for (int i = this.messages.size() - 1; i >= 0; --i) { for (int i = this.messages.size() - 1; i >= 0; --i) {
final Message message = messages.get(i); final Message message = messages.get(i);
final Jid mcp = message.getCounterpart();
if (mcp == null) {
continue;
}
final boolean counterpartMatch = mode == MODE_SINGLE ? final boolean counterpartMatch = mode == MODE_SINGLE ?
counterpart.asBareJid().equals(message.getCounterpart().asBareJid()) : counterpart.asBareJid().equals(mcp.asBareJid()) :
counterpart.equals(message.getCounterpart()); counterpart.equals(mcp);
if (counterpartMatch && ((message.getStatus() == Message.STATUS_RECEIVED) == received) if (counterpartMatch && ((message.getStatus() == Message.STATUS_RECEIVED) == received)
&& (carbon == message.isCarbon() || received)) { && (carbon == message.isCarbon() || received)) {
final boolean idMatch = id.equals(message.getRemoteMsgId()) || message.remoteMsgIdMatchInEdit(id); final boolean idMatch = id.equals(message.getRemoteMsgId()) || message.remoteMsgIdMatchInEdit(id);