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.
This commit is contained in:
Dmitry Podgorny
2015-10-23 01:28:19 +03:00
parent a54def3e92
commit 01af2deed9

View File

@@ -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;