[glib/glib-2-64: 1/2] gdesktopappinfo: Fix unnecessarily copied and leaked URI list



commit 47cdc8e35a3aaabf52f7f47a2e3c553c3b98a5df
Author: Felix Riemann <friemann gnome org>
Date:   Sat Jul 4 20:01:33 2020 +0200

    gdesktopappinfo: Fix unnecessarily copied and leaked URI list
    
    When an app is spawned using g_desktop_app_info_launch_uris_with_spawn
    it will expand the various token in the app's commandline with the
    URIs of the files to open. The expand_macro() function that is used for
    this advances the pointer to the URI list to show up to which entries
    it used.
    
    To not loose the pointer to the list head a duplicate of the URI list
    was actually passed to expand_macro(). However, it's not necessary to
    create a copy of the URI list for that as expand_macro() will only
    change which element the pointer will point to.
    
    This behaviour actually caused the duplicated list to be leaked as the
    the list pointer is NULL once all URIs are used up by expand_macro()
    and thus nothing was freed at the end of the function.

 gio/gdesktopappinfo.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
---
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
index ffd2ca317..fe3ebe20a 100644
--- a/gio/gdesktopappinfo.c
+++ b/gio/gdesktopappinfo.c
@@ -2727,7 +2727,7 @@ g_desktop_app_info_launch_uris_with_spawn (GDesktopAppInfo            *info,
    * internally by expand_macro(), so we need to pass a copy of it instead,
    * and also use that copy to control the exit condition of the loop below.
    */
-  dup_uris = g_list_copy (uris);
+  dup_uris = uris;
   do
     {
       GPid pid;
@@ -2864,7 +2864,6 @@ g_desktop_app_info_launch_uris_with_spawn (GDesktopAppInfo            *info,
   completed = TRUE;
 
  out:
-  g_list_free (dup_uris);
   g_strfreev (argv);
   g_strfreev (envp);
 


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