libsoup-2.2.97.mem-leak.awn.1.patch



2006-11-17  Andrew W. Nosenko  <andrew w nosenko gmail com>

	* libsoup/soup-message-client-io.c (parse_response_headers):
	Avoid memory leak when parse_response_headers() is called for
	message that have the 'reason_phrase' already for a some reason.

	* libsoup/soup-gnutls.c (soup_gnutls_free):
	Avoid memory leak: hostname was not freed.
	(soup_ssl_wrap_iochannel):
	Avoid memory leak: SoupGNUTLSChannel 'chan' was not freed in case
	of initialization error.
	
	* libsoup/soup-socket.c (soup_socket_start_proxy_ssl):
	Avoid memory leak: the "real" (plain, non-ssl) GIOChannel has
	never "finally" unrefed (one more *_ref() than *_unref()) in case
	of ssl-wrapping.
	* libsoup/soup-gnutls.c (soup_ssl_wrap_iochannel):
	Avoid double close of the "real" (plain, non-ssl) channel FD.

--
Andrew W. Nosenko <andrew w nosenko gmail com>
2006-11-17  Andrew W. Nosenko  <andrew w nosenko gmail com>

	* libsoup/soup-message-client-io.c (parse_response_headers): 
	Avoid memory leak when parse_response_headers() is called for
	message that have the 'reason_phrase' already for a some reason.

	* libsoup/soup-gnutls.c (soup_gnutls_free):
	Avoid memory leak: hostname was not freed.
	(soup_ssl_wrap_iochannel):
	Avoid memory leak: SoupGNUTLSChannel 'chan' was not freed in case
	of initialization error.
	
	* libsoup/soup-socket.c (soup_socket_start_proxy_ssl):
	Avoid memory leak: the "real" (plain, non-ssl) GIOChannel has
	never "finally" unrefed (one more *_ref() than *_unref()) in case
	of ssl-wrapping.
	* libsoup/soup-gnutls.c (soup_ssl_wrap_iochannel):
	Avoid double close of the "real" (plain, non-ssl) channel FD.

cvs server: Diffing libsoup
Index: libsoup/soup-gnutls.c
===================================================================
RCS file: /cvs/gnome/libsoup/libsoup/soup-gnutls.c,v
retrieving revision 1.19
diff -u -p -r1.19 soup-gnutls.c
--- libsoup/soup-gnutls.c	2 Apr 2006 21:46:18 -0000	1.19
+++ libsoup/soup-gnutls.c	17 Nov 2006 11:33:09 -0000
@@ -292,6 +292,7 @@ soup_gnutls_free (GIOChannel *channel)
 	SoupGNUTLSChannel *chan = (SoupGNUTLSChannel *) channel;
 	g_io_channel_unref (chan->real_sock);
 	gnutls_deinit (chan->session);
+	g_free(chan->hostname);
 	g_free (chan);
 }
 
@@ -409,7 +410,7 @@ soup_ssl_wrap_iochannel (GIOChannel *soc
 	gchan = (GIOChannel *) chan;
 	gchan->funcs = &soup_gnutls_channel_funcs;
 	g_io_channel_init (gchan);
-	g_io_channel_set_close_on_unref (gchan, TRUE);
+	g_io_channel_set_close_on_unref (gchan, FALSE);	/* FD will be closed by unref of real_chan. */
 	gchan->is_readable = gchan->is_writeable = TRUE;
 	gchan->use_buffer = FALSE;
 
@@ -418,6 +419,7 @@ soup_ssl_wrap_iochannel (GIOChannel *soc
  THROW_CREATE_ERROR:
 	if (session)
 		gnutls_deinit (session);
+	g_free(chan);
 	return NULL;
 }
 
Index: libsoup/soup-message-client-io.c
===================================================================
RCS file: /cvs/gnome/libsoup/libsoup/soup-message-client-io.c,v
retrieving revision 1.14
diff -u -p -r1.14 soup-message-client-io.c
--- libsoup/soup-message-client-io.c	21 Jul 2006 16:36:56 -0000	1.14
+++ libsoup/soup-message-client-io.c	17 Nov 2006 11:33:10 -0000
@@ -28,6 +28,8 @@ parse_response_headers (SoupMessage *req
 	SoupHttpVersion version;
 	GHashTable *resp_hdrs;
 
+	g_free((char*)req->reason_phrase);
+	req->reason_phrase = NULL;
 	if (!soup_headers_parse_response (headers, headers_len,
 					  req->response_headers,
 					  &version,
Index: libsoup/soup-socket.c
===================================================================
RCS file: /cvs/gnome/libsoup/libsoup/soup-socket.c,v
retrieving revision 1.68
diff -u -p -r1.68 soup-socket.c
--- libsoup/soup-socket.c	3 Nov 2006 18:31:08 -0000	1.68
+++ libsoup/soup-socket.c	17 Nov 2006 11:33:11 -0000
@@ -779,10 +779,11 @@ soup_socket_start_proxy_ssl (SoupSocket 
 {
 	SoupSocketPrivate *priv = SOUP_SOCKET_GET_PRIVATE (sock);
 	GIOChannel *ssl_chan;
+	GIOChannel *real_chan;
 
-	get_iochannel (priv);
+	real_chan = get_iochannel (priv);
 	ssl_chan = soup_ssl_wrap_iochannel (
-		priv->iochannel, priv->is_server ?
+		real_chan, priv->is_server ?
 		SOUP_SSL_TYPE_SERVER : SOUP_SSL_TYPE_CLIENT,
 		ssl_host, priv->ssl_creds);
 
@@ -790,6 +791,8 @@ soup_socket_start_proxy_ssl (SoupSocket 
 		return FALSE;
 
 	priv->iochannel = ssl_chan;
+	g_io_channel_unref(real_chan);	/* real_chan is ref'ed inside soup_ssl_wrap_iochannel() */
+
 	return TRUE;
 }
 	


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