diff options
author | Michael Vetter <jubalh@iodoru.org> | 2020-08-10 14:43:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-10 14:43:57 +0200 |
commit | 02cf1864768673f260272ab82500fe90ae56730f (patch) | |
tree | e32442e934aa9c0a3a19566f6b600baecfa33c58 | |
parent | 3e7776a9faa164bceaa1a1b6d8612fd68d075676 (diff) | |
parent | 7553676b40c3586b03c3b38027effbacaa62d36a (diff) | |
download | profani-tty-02cf1864768673f260272ab82500fe90ae56730f.tar.gz |
Merge pull request #1416 from profanity-im/memleaks2
Fix memory leak in _handle_chat()
-rw-r--r-- | src/xmpp/message.c | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 28b126a6..8e057e99 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -1239,17 +1239,10 @@ _handle_chat(xmpp_stanza_t* const stanza, gboolean is_mam, gboolean is_carbon, c } Jid* jid = jid_create(from); - Jid* to_jid = NULL; - const gchar* to = xmpp_stanza_get_to(stanza); - if (to) { - to_jid = jid_create(to); - } - // private message from chat room use full jid (room/nick) if (muc_active(jid->barejid)) { _handle_muc_private_message(stanza); jid_destroy(jid); - jid_destroy(to_jid); return; } @@ -1257,15 +1250,13 @@ _handle_chat(xmpp_stanza_t* const stanza, gboolean is_mam, gboolean is_carbon, c ProfMessage* message = message_init(); message->is_mam = is_mam; message->from_jid = jid; - if (to_jid) { - message->to_jid = to_jid; - } else { - if (is_carbon) { - // happens when receive a carbon of a self sent message - // really? maybe some servers do this, but it's not required. - Jid* from_jid = jid_create(from); - message->to_jid = from_jid; - } + const gchar* to = xmpp_stanza_get_to(stanza); + if (to) { + message->to_jid = jid_create(to); + } else if (is_carbon) { + // happens when receive a carbon of a self sent message + // really? maybe some servers do this, but it's not required. + message->to_jid = jid_create(from); } if (mucuser) { @@ -1274,11 +1265,6 @@ _handle_chat(xmpp_stanza_t* const stanza, gboolean is_mam, gboolean is_carbon, c message->type = PROF_MSG_TYPE_CHAT; } - const gchar* to_text = xmpp_stanza_get_to(stanza); - if (to_text) { - message->to_jid = jid_create(to_text); - } - // message stanza id const char* id = xmpp_stanza_get_id(stanza); if (id) { |