From 7909b7f9d8b9336b47890564d003010b1d63b61b Mon Sep 17 00:00:00 2001 From: Stefan Becker Date: Tue, 13 Dec 2011 23:17:49 +0200 Subject: [PATCH] valgrind: fix memory leak in http-conn.c When http_conn_free() was called while the HTTP connection was still pending then sipe_backend_transport_disconnect() wasn't called. Moved that call from http_conn_close() to http_conn_free() to fix this leak. Also noticed that there was an unused function http_conn_auth_free(). --- src/core/http-conn.c | 16 +++------------- src/core/http-conn.h | 3 --- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/core/http-conn.c b/src/core/http-conn.c index e216a4d6..2603a1b3 100644 --- a/src/core/http-conn.c +++ b/src/core/http-conn.c @@ -122,6 +122,9 @@ http_conn_free(HttpConn* http_conn) { if (!http_conn) return; + /* make sure also pending connections are released */ + sipe_backend_transport_disconnect(http_conn->conn); + /* don't free "http_conn->http_session" - client should do */ g_free(http_conn->method); g_free(http_conn->host); @@ -159,15 +162,6 @@ http_conn_session_free(HttpSession *http_session) } void -http_conn_auth_free(struct http_conn_auth* auth) -{ - g_free(auth->domain); - g_free(auth->user); - g_free(auth->password); - g_free(auth); -} - -void http_conn_set_close(HttpConn* http_conn) { http_conn->do_close = http_conn; @@ -177,10 +171,6 @@ static void http_conn_close(HttpConn *http_conn, const char *message) { SIPE_DEBUG_INFO("http_conn_close: closing http connection: %s", message ? message : ""); - - g_return_if_fail(http_conn); - - sipe_backend_transport_disconnect(http_conn->conn); http_conn_free(http_conn); } diff --git a/src/core/http-conn.h b/src/core/http-conn.h index dfaddbc5..d354e488 100644 --- a/src/core/http-conn.h +++ b/src/core/http-conn.h @@ -94,9 +94,6 @@ http_conn_set_close(HttpConn* http_conn); void http_conn_free(HttpConn* http_conn); -void -http_conn_auth_free(HttpConnAuth* auth); - HttpSession * http_conn_session_create(void); -- 2.11.4.GIT