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.
This commit is contained in:
Felix Riemann 2020-07-04 20:01:33 +02:00
parent b101dbda13
commit 88fe78137d

View File

@ -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);