[libsoup] Fix leaks, including a large one in SoupContentSniffer



commit abc8a146f4bc8936bb416de00fb4e57fca2a21bd
Author: Dan Winship <danw gnome org>
Date:   Fri Sep 11 11:46:45 2009 -0400

    Fix leaks, including a large one in SoupContentSniffer
    
    Fix a handful of leaks noticed by valgrind, including a leak of the
    buffers being passed to SoupContentSniffer
    (https://bugs.webkit.org/show_bug.cgi?id=28148).

 libsoup/soup-address.c       |    1 +
 libsoup/soup-connection.c    |    2 ++
 libsoup/soup-message-io.c    |    1 +
 libsoup/soup-message-queue.c |    4 ++++
 libsoup/soup-session.c       |    5 ++++-
 5 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/libsoup/soup-address.c b/libsoup/soup-address.c
index 0aa0547..d73ec82 100644
--- a/libsoup/soup-address.c
+++ b/libsoup/soup-address.c
@@ -571,6 +571,7 @@ update_addrs (SoupAddress *addr, GList *addrs, GError *error)
                  * and the buffer is large enough */
                 g_warn_if_reached ();
         }
+	g_object_unref (gsa);
 
 	return SOUP_STATUS_OK;
 }
diff --git a/libsoup/soup-connection.c b/libsoup/soup-connection.c
index c4a3846..a98cf34 100644
--- a/libsoup/soup-connection.c
+++ b/libsoup/soup-connection.c
@@ -90,6 +90,8 @@ finalize (GObject *object)
 		g_object_unref (priv->remote_addr);
 	if (priv->tunnel_addr)
 		g_object_unref (priv->tunnel_addr);
+	if (priv->proxy_uri)
+		soup_uri_free (priv->proxy_uri);
 
 	if (priv->async_context)
 		g_main_context_unref (priv->async_context);
diff --git a/libsoup/soup-message-io.c b/libsoup/soup-message-io.c
index cb2440e..d88a0a4 100644
--- a/libsoup/soup-message-io.c
+++ b/libsoup/soup-message-io.c
@@ -384,6 +384,7 @@ read_body_chunk (SoupMessage *msg)
 
 			if (io->need_content_sniffed) {
 				soup_message_body_append_buffer (io->sniff_data, buffer);
+				soup_buffer_free (buffer);
 				io->need_got_chunk = TRUE;
 				if (!io_handle_sniffing (msg, FALSE))
 					return FALSE;
diff --git a/libsoup/soup-message-queue.c b/libsoup/soup-message-queue.c
index bce5a16..61bc5ca 100644
--- a/libsoup/soup-message-queue.c
+++ b/libsoup/soup-message-queue.c
@@ -65,6 +65,10 @@ queue_message_restarted (SoupMessage *msg, gpointer user_data)
 		g_object_unref (item->proxy_addr);
 		item->proxy_addr = NULL;
 	}
+	if (item->proxy_uri) {
+		soup_uri_free (item->proxy_uri);
+		item->proxy_uri = NULL;
+	}
 	item->resolved_proxy_addr = FALSE;
 }
 
diff --git a/libsoup/soup-session.c b/libsoup/soup-session.c
index c8c1b34..783fbfb 100644
--- a/libsoup/soup-session.c
+++ b/libsoup/soup-session.c
@@ -1067,6 +1067,7 @@ soup_session_make_connect_message (SoupSession *session,
 	SoupSessionPrivate *priv = SOUP_SESSION_GET_PRIVATE (session);
 	SoupURI *uri;
 	SoupMessage *msg;
+	SoupMessageQueueItem *item;
 
 	uri = soup_uri_new (NULL);
 	soup_uri_set_scheme (uri, SOUP_URI_SCHEME_HTTPS);
@@ -1082,7 +1083,9 @@ soup_session_make_connect_message (SoupSession *session,
 	 * the right signals to be emitted.
 	 */
 	queue_message (session, msg, tunnel_connected, NULL);
-	return soup_message_queue_lookup (priv->queue, msg);
+	item = soup_message_queue_lookup (priv->queue, msg);
+	g_object_unref (msg);
+	return item;
 }
 
 /**



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]