From c319ee65833fc85e067525b43e9795dbffa5a79e Mon Sep 17 00:00:00 2001 From: Dmitry Podgorny Date: Sat, 1 Jul 2017 16:24:30 +0300 Subject: [PATCH] handler: fix memory leak and use-after-free errors The errors are related to newly added handler_system_delete_all(). --- src/conn.c | 3 ++- src/handler.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/conn.c b/src/conn.c index f4e19a7..bea84eb 100644 --- a/src/conn.c +++ b/src/conn.c @@ -264,6 +264,8 @@ int xmpp_conn_release(xmpp_conn_t * const conn) } } + _conn_reset(conn); + /* free handler stuff * note that userdata is the responsibility of the client * and the handler pointers don't need to be freed since they @@ -305,7 +307,6 @@ int xmpp_conn_release(xmpp_conn_t * const conn) } parser_free(conn->parser); - _conn_reset(conn); if (conn->jid) xmpp_free(ctx, conn->jid); if (conn->pass) xmpp_free(ctx, conn->pass); diff --git a/src/handler.c b/src/handler.c index 8a9e179..1f5dbaa 100644 --- a/src/handler.c +++ b/src/handler.c @@ -686,4 +686,5 @@ void handler_system_delete_all(xmpp_conn_t *conn) xmpp_free(conn->ctx, key2); } } + if (iter) hash_iter_release(iter); }