From: Dan Winship Date: Tue, 9 Nov 2010 14:57:55 +0000 (-0500) Subject: SoupContentDecoder: fix an unlikely leak X-Git-Tag: LIBSOUP_2_32_1~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=635647ef5d07aaddcbe6f9aa63d6fed6d090e419;p=platform%2Fupstream%2Flibsoup.git 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. --- 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,