[frogr] Fix memory leaks opening URIs in external applications



commit db48c968f0f56409a29ffb124ad048391f8ff2c4
Author: Mario Sanchez Prada <msanchez igalia com>
Date:   Sat Apr 14 16:02:07 2012 +0200

    Fix memory leaks opening URIs in external applications

 src/frogr-main-view.c |    7 +------
 src/frogr-util.c      |   12 +++---------
 2 files changed, 4 insertions(+), 15 deletions(-)
---
diff --git a/src/frogr-main-view.c b/src/frogr-main-view.c
index 4e93147..25a84f7 100644
--- a/src/frogr-main-view.c
+++ b/src/frogr-main-view.c
@@ -1095,7 +1095,6 @@ _open_pictures_in_external_viewer (FrogrMainView *self)
   GSList *current_pic = NULL;
   GList *uris_list = NULL;
   FrogrPicture *picture = NULL;
-  gchar *fileuri = NULL;
 
   if (!_pictures_selected_required_check (self))
     return;
@@ -1104,16 +1103,12 @@ _open_pictures_in_external_viewer (FrogrMainView *self)
   for (current_pic = pictures; current_pic; current_pic = g_slist_next (current_pic))
     {
       picture = FROGR_PICTURE (current_pic->data);
-      fileuri = g_strdup (frogr_picture_get_fileuri (picture));
-
-      /* Dupped uris in the GList must NOT be freed here */
-      uris_list = g_list_append (uris_list, fileuri);
+      uris_list = g_list_append (uris_list, (gchar *) frogr_picture_get_fileuri (picture));
     }
   g_slist_foreach (pictures, (GFunc) g_object_unref, NULL);
   g_slist_free (pictures);
 
   frogr_util_open_images_in_viewer (uris_list);
-
   g_list_free (uris_list);
 }
 
diff --git a/src/frogr-util.c b/src/frogr-util.c
index daa92df..98e81e5 100644
--- a/src/frogr-util.c
+++ b/src/frogr-util.c
@@ -123,7 +123,7 @@ _get_uris_string_from_list (GList *uris_list)
     uris_array[i++] = (gchar *) (current_uri->data);
 
   uris_str = g_strjoinv (" ", uris_array);
-  g_strfreev (uris_array);
+  g_free (uris_array);
 
   return uris_str;
 }
@@ -140,7 +140,6 @@ _open_uris_with_app_info (GList *uris_list, GAppInfo *app_info)
   if (!app_info || !g_app_info_launch_uris (app_info, uris_list, NULL, &error))
     {
       /* The default app didn't succeed, so try 'gnome-open' / 'open' */
-
       gchar *command = NULL;
       gchar *uris = NULL;
 
@@ -152,7 +151,6 @@ _open_uris_with_app_info (GList *uris_list, GAppInfo *app_info)
 #else
       command = g_strdup_printf ("gnome-open %s", uris);
 #endif
-
       _spawn_command (command);
 
       if (error)
@@ -176,9 +174,8 @@ _open_uri_for_mac (const gchar *uri)
   if (!uri)
     return;
 
-  uris_list = g_list_append (uris_list, g_strdup (uri));
+  uris_list = g_list_append (uris_list, (gchar*) uri);
   _open_uris_with_app_info (uris_list, NULL);
-
   g_list_free (uris_list);
 }
 #endif
@@ -196,9 +193,6 @@ _open_uri_for_gnome (const gchar *uri)
   if (!uri)
     return;
 
-  /* Dupped uris in the GList must NOT be freed here */
-  uris_list = g_list_append (uris_list, g_strdup (uri));
-
   /* Supported network URIs */
   if (g_str_has_prefix (uri, "http:") || g_str_has_prefix (uri, "https:"))
     {
@@ -217,8 +211,8 @@ _open_uri_for_gnome (const gchar *uri)
       app_info = help_app_info;
     }
 
+  uris_list = g_list_append (uris_list, (gchar *) uri);
   _open_uris_with_app_info (uris_list, app_info);
-
   g_list_free (uris_list);
 }
 #endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]