From: Christian Dywan Date: Mon, 28 Nov 2011 20:21:29 +0000 (+0100) Subject: Clean up allocations in adblock_add_url_pattern X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ffd3026baf5aecb27d51399f8896a693279783f6;p=midori Clean up allocations in adblock_add_url_pattern --- diff --git a/extensions/adblock.c b/extensions/adblock.c index 4e5ae064..d41bd851 100644 --- a/extensions/adblock.c +++ b/extensions/adblock.c @@ -1128,31 +1128,35 @@ adblock_add_url_pattern (gchar* prefix, data = g_strsplit (line, "$", -1); if (!data || !data[0]) + { + g_strfreev (data); return NULL; + } if (data[1] && data[2]) { patt = g_strconcat (data[0], data[1], NULL); opts = g_strconcat (type, ",", data[2], NULL); - g_strfreev (data); } else if (data[1]) { patt = data[0]; opts = g_strconcat (type, ",", data[1], NULL); - g_free (data[1]); } else { patt = data[0]; - opts = g_strdup (type); + opts = type; } if (g_regex_match_simple ("subdocument", opts, G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY)) { - g_free (patt); - g_free (opts); + g_strfreev (data); + if (data[1] && data[2]) + g_free (patt); + if (data[1]) + g_free (opts); return NULL; } @@ -1161,14 +1165,13 @@ adblock_add_url_pattern (gchar* prefix, adblock_debug ("got: %s opts %s", format_patt->str, opts); should_free = adblock_compile_regexp (format_patt, opts); - g_free (opts); - g_free (patt); + g_strfreev (data); + if (data[1] && data[2]) + g_free (patt); + if (data[1]) + g_free (opts); - #if G_ENABLE_DEBUG - return g_string_free (format_patt, FALSE); - #else return g_string_free (format_patt, should_free); - #endif } static inline void