mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-28 08:26:14 +01:00
gutils: Fix g_find_program_in_path() to return an absolute path
Fix a possibility of returning a relative path, in case PATH contains a relative path. According to the doc, the function should return an absolute path. Signed-off-by: Christoph Niethammer <christoph.niethammer@gmail.com>
This commit is contained in:
parent
4d97fef04c
commit
78dc1cc3cd
@ -456,7 +456,14 @@ g_find_program_in_path (const gchar *program)
|
|||||||
!g_file_test (startp, G_FILE_TEST_IS_DIR))
|
!g_file_test (startp, G_FILE_TEST_IS_DIR))
|
||||||
{
|
{
|
||||||
gchar *ret;
|
gchar *ret;
|
||||||
|
if (g_path_is_absolute (startp)) {
|
||||||
ret = g_strdup (startp);
|
ret = g_strdup (startp);
|
||||||
|
} else {
|
||||||
|
gchar *cwd = NULL;
|
||||||
|
cwd = g_get_current_dir ();
|
||||||
|
ret = g_build_filename (cwd, startp, NULL);
|
||||||
|
g_free (cwd);
|
||||||
|
}
|
||||||
g_free (freeme);
|
g_free (freeme);
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
g_free ((gchar *) path_copy);
|
g_free ((gchar *) path_copy);
|
||||||
|
Loading…
Reference in New Issue
Block a user