From 01af2deed9afb8f5663553be181e42bc150e96df Mon Sep 17 00:00:00 2001 From: Dmitry Podgorny Date: Fri, 23 Oct 2015 01:28:19 +0300 Subject: [PATCH] conn: fixed memory leak Memory leak appeared when xmpp_connect_client() was called for a connection more than once. In this case conn->domain wasn't freed. --- src/conn.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/conn.c b/src/conn.c index 57b4736..f621aa7 100644 --- a/src/conn.c +++ b/src/conn.c @@ -403,6 +403,8 @@ int xmpp_connect_client(xmpp_conn_t * const conn, if (conn->state != XMPP_STATE_DISCONNECTED) return -1; + if (conn->domain != NULL) + xmpp_free(conn->ctx, conn->domain); conn->type = XMPP_CLIENT; conn->secured = 0; @@ -487,6 +489,8 @@ int xmpp_connect_component(xmpp_conn_t * const conn, const char * const server, if (conn->state != XMPP_STATE_DISCONNECTED) return -1; + if (conn->domain != NULL) + xmpp_free(conn->ctx, conn->domain); conn->type = XMPP_COMPONENT; conn->secured = 0;