1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Merge pull request #1132 from paulfariello/hotfix/muc-history-segfault

Fix NULL pointer when handling non encrypted message in MUC
This commit is contained in:
Michael Vetter 2019-06-21 11:47:12 +02:00 committed by GitHub
commit 4b62f8f2ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -800,6 +800,8 @@ _handle_groupchat(xmpp_stanza_t *const stanza)
message->jid = jid; message->jid = jid;
message->id = strdup(id); message->id = strdup(id);
message->body = xmpp_message_get_body(stanza);
// check omemo encryption // check omemo encryption
#ifdef HAVE_OMEMO #ifdef HAVE_OMEMO
message->plain = omemo_receive_message(stanza, &message->trusted); message->plain = omemo_receive_message(stanza, &message->trusted);
@ -808,7 +810,12 @@ _handle_groupchat(xmpp_stanza_t *const stanza)
} }
#endif #endif
message->body = xmpp_message_get_body(stanza); if (!message->plain && !message->body) {
log_error("Message received without body for room: %s", jid->str);
goto out;
} else if (!message->plain) {
message->plain = strdup(message->body);
}
// determine if the notifications happened whilst offline // determine if the notifications happened whilst offline
message->timestamp = stanza_get_delay(stanza); message->timestamp = stanza_get_delay(stanza);
@ -818,6 +825,7 @@ _handle_groupchat(xmpp_stanza_t *const stanza)
sv_ev_room_message(message); sv_ev_room_message(message);
} }
out:
message_free(message); message_free(message);
} }