fix potential memory leak
If functions `xmpp_conn_set_cafile()` or `xmpp_conn_set_capath()` are called twice they leaked the previously allocated memory. Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
This commit is contained in:
@@ -481,6 +481,8 @@ void xmpp_conn_set_certfail_handler(xmpp_conn_t *const conn,
|
|||||||
*/
|
*/
|
||||||
void xmpp_conn_set_cafile(xmpp_conn_t *const conn, const char *path)
|
void xmpp_conn_set_cafile(xmpp_conn_t *const conn, const char *path)
|
||||||
{
|
{
|
||||||
|
if (conn->tls_cafile)
|
||||||
|
strophe_free(conn->ctx, conn->tls_cafile);
|
||||||
conn->tls_cafile = strophe_strdup(conn->ctx, path);
|
conn->tls_cafile = strophe_strdup(conn->ctx, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,6 +495,8 @@ void xmpp_conn_set_cafile(xmpp_conn_t *const conn, const char *path)
|
|||||||
*/
|
*/
|
||||||
void xmpp_conn_set_capath(xmpp_conn_t *const conn, const char *path)
|
void xmpp_conn_set_capath(xmpp_conn_t *const conn, const char *path)
|
||||||
{
|
{
|
||||||
|
if (conn->tls_capath)
|
||||||
|
strophe_free(conn->ctx, conn->tls_capath);
|
||||||
conn->tls_capath = strophe_strdup(conn->ctx, path);
|
conn->tls_capath = strophe_strdup(conn->ctx, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user