[Xfce4-commits] <garcon:master> Fix memory leaks in garcon_menu_item_new.
Nick Schermer
nick at xfce.org
Sun Aug 16 18:06:06 CEST 2009
Updating branch refs/heads/master
to 7c0663052cf2f48a5fef5b63339a7e538fb19bb1 (commit)
from e3155d694770f29d838286423c36942f29c0280b (commit)
commit 7c0663052cf2f48a5fef5b63339a7e538fb19bb1
Author: Nick Schermer <nick at xfce.org>
Date: Sun Aug 16 13:10:38 2009 +0200
Fix memory leaks in garcon_menu_item_new.
garcon/garcon-menu-item.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/garcon/garcon-menu-item.c b/garcon/garcon-menu-item.c
index 252a1c0..55d24e3 100644
--- a/garcon/garcon-menu-item.c
+++ b/garcon/garcon-menu-item.c
@@ -530,7 +530,7 @@ GarconMenuItem *
garcon_menu_item_new (const gchar *uri)
{
GarconMenuItem *item = NULL;
- GKeyFile *rc;
+ GKeyFile *rc = NULL;
GError *error = NULL;
GFile *file;
GList *categories = NULL;
@@ -556,7 +556,7 @@ garcon_menu_item_new (const gchar *uri)
/* Return NULL if the filename is not an absolute path or if the file does not exists */
if (G_UNLIKELY (!g_path_is_absolute (filename) || !g_file_test (filename, G_FILE_TEST_EXISTS)))
- return NULL;
+ goto error;
/* Try to open the .desktop file */
rc = g_key_file_new ();
@@ -564,15 +564,12 @@ garcon_menu_item_new (const gchar *uri)
if (G_UNLIKELY (error != NULL))
{
g_error_free (error);
- return NULL;
+ goto error;
}
/* Abort if the file has been marked as "deleted"/hidden */
if (G_UNLIKELY (g_key_file_get_boolean (rc, "Desktop Entry", "Hidden", NULL)))
- {
- g_key_file_free (rc);
- return NULL;
- }
+ goto error;
/* Parse name, exec command and icon name */
name = g_key_file_get_locale_string (rc, "Desktop Entry", "Name", NULL, NULL);
@@ -637,9 +634,12 @@ garcon_menu_item_new (const gchar *uri)
g_free (try_exec);
g_free (icon);
g_free (path);
+error:
+ g_free (filename);
/* Close file handle */
- g_key_file_free (rc);
+ if (G_LIKELY (rc != NULL))
+ g_key_file_free (rc);
return item;
}
More information about the Xfce4-commits
mailing list