22# so GAppInfo will ignore them
33
44diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
5- index 63ef0c045..fa5ade90a 100644
5+ index 1f161328a..4184d40f0 100644
66--- a/gio/gdesktopappinfo.c
77+++ b/gio/gdesktopappinfo.c
8- @@ -1787,47 +1787 ,11 @@ g_desktop_app_info_load_from_keyfile (GDesktopAppInfo *info,
8+ @@ -1910,56 +1910 ,11 @@ g_desktop_app_info_load_from_keyfile (GDesktopAppInfo *info,
99 G_KEY_FILE_DESKTOP_GROUP,
1010 G_KEY_FILE_DESKTOP_KEY_TRY_EXEC,
1111 NULL);
1212- if (try_exec && try_exec[0] != '\0')
1313- {
1414- char *t;
15- - t = g_find_program_in_path (try_exec);
15+ - /* Use the desktop file path (if any) as working dir to search program */
16+ - t = GLIB_PRIVATE_CALL (g_find_program_for_path) (try_exec, NULL, path);
1617- if (t == NULL)
1718- {
19+ - g_free (path);
1820- g_free (try_exec);
1921- return FALSE;
2022- }
2123- g_free (t);
2224- }
23-
25+
2426 exec = g_key_file_get_string (key_file,
2527 G_KEY_FILE_DESKTOP_GROUP,
2628 G_KEY_FILE_DESKTOP_KEY_EXEC,
@@ -31,25 +33,32 @@ index 63ef0c045..fa5ade90a 100644
3133- char **argv;
3234- if (!g_shell_parse_argv (exec, &argc, &argv, NULL))
3335- {
36+ - g_free (path);
3437- g_free (exec);
3538- g_free (try_exec);
3639- return FALSE;
3740- }
3841- else
3942- {
4043- char *t;
41- - t = g_find_program_in_path (argv[0]);
44+ -
45+ - /* Since @exec is not an empty string, there must be at least one
46+ - * argument, so dereferencing argv[0] should return non-NULL. */
47+ - g_assert (argc > 0);
48+ - /* Use the desktop file path (if any) as working dir to search program */
49+ - t = GLIB_PRIVATE_CALL (g_find_program_for_path) (argv[0], NULL, path);
4250- g_strfreev (argv);
4351-
4452- if (t == NULL)
4553- {
54+ - g_free (path);
4655- g_free (exec);
4756- g_free (try_exec);
4857- return FALSE;
4958- }
5059- g_free (t);
5160- }
5261- }
53-
62+
5463 info->name = g_key_file_get_locale_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_NAME, NULL, NULL);
5564 info->generic_name = g_key_file_get_locale_string (key_file, G_KEY_FILE_DESKTOP_GROUP, GENERIC_NAME_KEY, NULL, NULL);
0 commit comments