From 5ec1b03cbc838a1102407b01a18f2fa1e4b6ca64 Mon Sep 17 00:00:00 2001 From: Michael Vetter Date: Tue, 21 Apr 2020 17:11:04 +0200 Subject: [PATCH] _handle_carbons(): fix potential memleak --- src/xmpp/message.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/xmpp/message.c b/src/xmpp/message.c index d8d12a74..c9972621 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -1114,8 +1114,6 @@ _handle_carbons(xmpp_stanza_t *const stanza) } #endif - message->body = xmpp_message_get_body(message_stanza); - const gchar *to = xmpp_stanza_get_to(message_stanza); const gchar *from = xmpp_stanza_get_from(message_stanza); @@ -1125,8 +1123,12 @@ _handle_carbons(xmpp_stanza_t *const stanza) Jid *jid_from = jid_create(from); Jid *jid_to = jid_create(to); + message->body = xmpp_message_get_body(message_stanza); + if (!message->plain && !message->body) { log_error("Message received without body from: %s", jid_from->fulljid); + jid_destroy(jid_from); + jid_destroy(jid_to); goto out; } else if (!message->plain) { message->plain = strdup(message->body);