From d5938ea8e68d2abba28154e1da909c16ca24fa1d Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Wed, 5 Aug 2020 12:09:16 +0200 Subject: launcher: Fix memory leaks --- mate-panel/launcher.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/mate-panel/launcher.c b/mate-panel/launcher.c index 7215c357..9b559bbb 100644 --- a/mate-panel/launcher.c +++ b/mate-panel/launcher.c @@ -909,6 +909,7 @@ launcher_load_from_gsettings (PanelWidget *panel_widget, if (!launcher_location) { g_printerr (_("Key %s is not set, cannot load launcher\n"), PANEL_OBJECT_LAUNCHER_LOCATION_KEY); + g_object_unref (settings); return; } @@ -1044,6 +1045,7 @@ panel_launcher_create_from_info (PanelToplevel *toplevel, g_error_free (error); } + g_free (location); g_key_file_free (key_file); } @@ -1106,11 +1108,10 @@ panel_launcher_create_copy (PanelToplevel *toplevel, int position, const char *location) { - char *new_location; - GFile *source; - GFile *dest; - gboolean copied; - const char *filename; + char *new_location; + GFile *source; + GFile *dest; + gboolean copied; new_location = panel_make_unique_desktop_uri (NULL, location); @@ -1120,16 +1121,19 @@ panel_launcher_create_copy (PanelToplevel *toplevel, copied = g_file_copy (source, dest, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, NULL); - if (!copied) { - g_free (new_location); - return FALSE; + if (copied) { + gchar *filename; + + filename = panel_launcher_get_filename (new_location); + panel_launcher_create (toplevel, position, filename); + g_free (filename); } - filename = panel_launcher_get_filename (new_location); - panel_launcher_create (toplevel, position, filename); + g_object_unref (source); + g_object_unref (dest); g_free (new_location); - return TRUE; + return copied; } Launcher * -- cgit v1.2.1