mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-28 16:36:14 +01:00
gutils: ensure g_find_program_in_path() return an absolute path
Fix a possibility of returning a relative path, according to the doc, the function should return an absolute path. Signed-off-by: Luke Yue <lukedyue@gmail.com>
This commit is contained in:
parent
11c0b2e597
commit
dba1fce993
@ -340,7 +340,17 @@ g_find_program_in_path (const gchar *program)
|
||||
{
|
||||
if (g_file_test (program, G_FILE_TEST_IS_EXECUTABLE) &&
|
||||
!g_file_test (program, G_FILE_TEST_IS_DIR))
|
||||
return g_strdup (program);
|
||||
{
|
||||
gchar *out = NULL, *cwd = NULL;
|
||||
|
||||
if (g_path_is_absolute (program))
|
||||
return g_strdup (program);
|
||||
|
||||
cwd = g_get_current_dir ();
|
||||
out = g_build_filename (cwd, program, NULL);
|
||||
g_free (cwd);
|
||||
return g_steal_pointer (&out);
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user