diff options
author | Dmitry Podgorny <pasis.ua@gmail.com> | 2020-08-07 00:47:45 +0300 |
---|---|---|
committer | Dmitry Podgorny <pasis.ua@gmail.com> | 2020-08-07 00:47:45 +0300 |
commit | 7553676b40c3586b03c3b38027effbacaa62d36a (patch) | |
tree | e32442e934aa9c0a3a19566f6b600baecfa33c58 /src | |
parent | 3e7776a9faa164bceaa1a1b6d8612fd68d075676 (diff) | |
download | profani-tty-7553676b40c3586b03c3b38027effbacaa62d36a.tar.gz |
Fix memory leak in _handle_chat()
jid_create() for attribute "to" was called twice and the 1st object was lost.
Diffstat (limited to 'src')
-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) { |