From 240f6a3f79e42c0463ae4c1cc221efd7883463fd Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 24 Jun 2015 20:53:04 +0100 Subject: [PATCH] Fixed various jid and account mem leaks --- src/command/commands.c | 2 ++ src/config/accounts.c | 2 ++ src/jid.c | 2 +- src/xmpp/connection.c | 1 + src/xmpp/message.c | 3 +++ src/xmpp/presence.c | 1 + 6 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/command/commands.c b/src/command/commands.c index c4f9ae84..3f9009b4 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -226,6 +226,7 @@ cmd_connect(ProfWin *window, gchar **args, struct cmd_help_t help) } else { cons_show("Error evaluating password, see logs for details."); g_free(lower); + account_free(account); return TRUE; } @@ -2179,6 +2180,7 @@ cmd_join(ProfWin *window, gchar **args, struct cmd_help_t help) if (!parsed) { cons_show("Usage: %s", help.usage); cons_show(""); + jid_destroy(room_arg); return TRUE; } diff --git a/src/config/accounts.c b/src/config/accounts.c index 218e9d30..a827392b 100644 --- a/src/config/accounts.c +++ b/src/config/accounts.c @@ -411,6 +411,8 @@ accounts_set_jid(const char * const account_name, const char * const value) _save_accounts(); } + + jid_destroy(jid); } } diff --git a/src/jid.c b/src/jid.c index baeeb279..172ca5b9 100644 --- a/src/jid.c +++ b/src/jid.c @@ -192,4 +192,4 @@ jid_fulljid_or_barejid(Jid *jid) } else { return jid->barejid; } -} \ No newline at end of file +} diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index 8fa83144..3c9ba214 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -366,6 +366,7 @@ _jabber_connect(const char * const fulljid, const char * const passwd, } else if (jid->fulljid == NULL) { log_error("Full JID required to connect, received: %s", fulljid); jabber_conn.conn_status = JABBER_DISCONNECTED; + jid_destroy(jid); return jabber_conn.conn_status; } diff --git a/src/xmpp/message.c b/src/xmpp/message.c index 4cc440ea..863c2d87 100644 --- a/src/xmpp/message.c +++ b/src/xmpp/message.c @@ -170,6 +170,7 @@ message_send_chat_pgp(const char * const barejid, const char * const msg) } else { message = stanza_create_message(ctx, id, jid, STANZA_TYPE_CHAT, msg); } + jid_destroy(jidp); } else { message = stanza_create_message(ctx, id, jid, STANZA_TYPE_CHAT, msg); } @@ -449,6 +450,7 @@ _conference_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void // XEP-0249 char *room = xmpp_stanza_get_attribute(xns_conference, STANZA_ATTR_JID); if (!room) { + jid_destroy(jidp); return 1; } @@ -754,6 +756,7 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * con // private message from chat room use full jid (room/nick) if (muc_active(jid->barejid)) { _private_chat_handler(stanza, jid->fulljid); + jid_destroy(jid); return 1; } diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c index 4cf648dc..42215322 100644 --- a/src/xmpp/presence.c +++ b/src/xmpp/presence.c @@ -670,6 +670,7 @@ _muc_user_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * // invalid from attribute Jid *from_jid = jid_create(from); if (from_jid == NULL || from_jid->resourcepart == NULL) { + jid_destroy(from_jid); return 1; }