[libsoup] SoupContentDecoder: fix an unlikely leak



commit 635647ef5d07aaddcbe6f9aa63d6fed6d090e419
Author: Dan Winship <danw gnome org>
Date:   Tue Nov 9 09:57:55 2010 -0500

    SoupContentDecoder: fix an unlikely leak
    
    In particular, this can happen if you accidentally install two content
    decoders on the same session. Pointed out a long time ago in email by
    Christophe Gillette.

 libsoup/soup-content-decoder.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/libsoup/soup-content-decoder.c b/libsoup/soup-content-decoder.c
index 24ea751..7bc6f42 100644
--- a/libsoup/soup-content-decoder.c
+++ b/libsoup/soup-content-decoder.c
@@ -117,7 +117,7 @@ soup_content_decoder_got_headers_cb (SoupMessage *msg, SoupContentDecoder *decod
 	const char *header;
 	GSList *encodings, *e;
 	GType coding_type;
-	SoupCoding *coding; 
+	SoupCoding *coding;
 
 	header = soup_message_headers_get_list (msg->response_headers,
 						"Content-Encoding");
@@ -138,7 +138,14 @@ soup_content_decoder_got_headers_cb (SoupMessage *msg, SoupContentDecoder *decod
 		}
 	}
 
-	msgpriv->decoders = NULL;
+	/* msgpriv->decoders should be empty at this point anyway, but
+	 * clean it up if it's not.
+	 */
+	while (msgpriv->decoders) {
+		g_object_unref (msgpriv->decoders->data);
+		msgpriv->decoders = g_slist_delete_link (msgpriv->decoders, msgpriv->decoders);
+	}
+
 	for (e = encodings; e; e = e->next) {
 		coding_type = (GType) GPOINTER_TO_SIZE (g_hash_table_lookup (decoder->priv->codings, e->data));
 		coding = g_object_new (coding_type,



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