From 45e8467231c50363a4f7879401d523a703362085 Mon Sep 17 00:00:00 2001 From: Paul Fariello Date: Fri, 21 Jun 2019 13:53:46 +0200 Subject: [PATCH] Fix a segfault when carbon has no body --- src/xmpp/message.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 55f332b2..09863b63 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -1004,17 +1004,19 @@ _handle_carbons(xmpp_stanza_t *const stanza) message->encrypted = xmpp_stanza_get_text(x); } - // if we are the recipient, treat as standard incoming message - if (g_strcmp0(my_jid->barejid, jid_to->barejid) == 0) { - jid_destroy(jid_to); - message->jid = jid_from; - sv_ev_incoming_carbon(message); + if (message->plain || message->encrypted || message->body) { + // if we are the recipient, treat as standard incoming message + if (g_strcmp0(my_jid->barejid, jid_to->barejid) == 0) { + jid_destroy(jid_to); + message->jid = jid_from; + sv_ev_incoming_carbon(message); - // else treat as a sent message - } else { - jid_destroy(jid_from); - message->jid = jid_to; - sv_ev_outgoing_carbon(message); + // else treat as a sent message + } else { + jid_destroy(jid_from); + message->jid = jid_to; + sv_ev_outgoing_carbon(message); + } } message_free(message);