From d013cc85a9cac7fd8922b687b0cd6fb6822fbce6 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Mon, 10 Oct 2011 21:55:12 +0200 Subject: [PATCH] Use goto to not leak parts in midori_view_update_icon --- midori/midori-view.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/midori/midori-view.c b/midori/midori-view.c index 66db05eb..55782709 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -756,27 +756,29 @@ midori_view_update_icon (MidoriView* view, if (!((parts = g_strsplit (view->mime_type, "/", 2)) && (*parts && parts[1]))) { - g_strfreev (parts); /* This is a hack to have a Find icon in the location while the blank page has a File icon. */ icon = gtk_widget_render_icon (GTK_WIDGET (view), GTK_STOCK_FIND, GTK_ICON_SIZE_MENU, NULL); midori_view_apply_icon (view, icon, GTK_STOCK_FILE); - return; + goto free_parts; } if (midori_view_mime_icon (view, theme, "%s-%s", *parts, parts[1])) - return; + goto free_parts; if (midori_view_mime_icon (view, theme, "gnome-mime-%s-%s", *parts, parts[1])) - return; + goto free_parts; if (midori_view_mime_icon (view, theme, "%s-x-generic", *parts, NULL)) - return; + goto free_parts; if (midori_view_mime_icon (view, theme, "gnome-mime-%s-x-generic", *parts, NULL)) - return; + goto free_parts; icon = gtk_widget_render_icon (GTK_WIDGET (view), GTK_STOCK_FILE, GTK_ICON_SIZE_MENU, NULL); midori_view_apply_icon (view, icon, NULL); + +free_parts: + g_strfreev (parts); } typedef struct