about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-04-21 17:11:04 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-04-21 17:11:04 +0200
commit5ec1b03cbc838a1102407b01a18f2fa1e4b6ca64 (patch)
tree11efaa5583b565a6a966bec29210a80e5558841a /src/xmpp
parent813fd637a1e76f11daa488ee568059e4ddff35fb (diff)
downloadprofani-tty-5ec1b03cbc838a1102407b01a18f2fa1e4b6ca64.tar.gz
_handle_carbons(): fix potential memleak
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/message.c6
1 files 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);