mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-28 06:56:16 +01:00
gutils: Avoid possible leaks in g_find_program_for_path()
Signed-off-by: Philip Withnall <pwithnall@endlessos.org> Fixes: #2871
This commit is contained in:
parent
a7d523cd08
commit
db2381026f
@ -348,14 +348,18 @@ g_find_program_for_path (const char *program,
|
|||||||
!g_file_test (program, G_FILE_TEST_IS_DIR))
|
!g_file_test (program, G_FILE_TEST_IS_DIR))
|
||||||
{
|
{
|
||||||
gchar *out = NULL;
|
gchar *out = NULL;
|
||||||
char *cwd;
|
|
||||||
|
|
||||||
if (g_path_is_absolute (program))
|
if (g_path_is_absolute (program))
|
||||||
return g_strdup (program);
|
{
|
||||||
|
out = g_strdup (program);
|
||||||
cwd = g_get_current_dir ();
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char *cwd = g_get_current_dir ();
|
||||||
out = g_build_filename (cwd, program, NULL);
|
out = g_build_filename (cwd, program, NULL);
|
||||||
g_free (cwd);
|
g_free (cwd);
|
||||||
|
}
|
||||||
|
|
||||||
g_free (program_path);
|
g_free (program_path);
|
||||||
|
|
||||||
return g_steal_pointer (&out);
|
return g_steal_pointer (&out);
|
||||||
@ -499,6 +503,8 @@ g_find_program_for_path (const char *program,
|
|||||||
ret = g_build_filename (cwd, startp, NULL);
|
ret = g_build_filename (cwd, startp, NULL);
|
||||||
g_free (cwd);
|
g_free (cwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free (program_path);
|
||||||
g_free (startp_path);
|
g_free (startp_path);
|
||||||
g_free (freeme);
|
g_free (freeme);
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
@ -511,6 +517,7 @@ g_find_program_for_path (const char *program,
|
|||||||
}
|
}
|
||||||
while (*p++ != '\0');
|
while (*p++ != '\0');
|
||||||
|
|
||||||
|
g_free (program_path);
|
||||||
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