mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-12-06 00:24:50 +01:00
gtestutils: Handle empty argv array passed to g_test_init()
This can happen if a caller (ab)uses `execve()` to execute a gtest process with an empty `argv` array. `g_test_init()` has to gracefully handle such a situation. Fix a few problem areas in the code, and add a simple test which checks that `g_test_init()` doesn’t crash when called with an empty `argv`. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
@@ -668,8 +668,8 @@ parse_args (gint *argc_p,
|
||||
}
|
||||
}
|
||||
/* collapse argv */
|
||||
e = 1;
|
||||
for (i = 1; i < argc; i++)
|
||||
e = 0;
|
||||
for (i = 0; i < argc; i++)
|
||||
if (argv[i])
|
||||
{
|
||||
argv[e++] = argv[i];
|
||||
|
||||
Reference in New Issue
Block a user