glib/spawn-win32: workaround SEGV on spawnvpe

I haven't been able to write a reproducer yet and report the bug to
Microsoft, but this is 100% crashing when running "meson test
gsubprocess"

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau 2022-02-03 19:55:34 +04:00
parent 2ebe30e170
commit 68aff6dd07

View File

@ -637,6 +637,13 @@ fork_exec (gint *exit_status,
argc = protect_argv (argv, &protected_argv);
/*
* FIXME: Workaround broken spawnvpe functions that SEGV when "=X:="
* environment variables are missing. Calling chdir() will set the magic
* environment variable again.
*/
_chdir (".");
if (stdin_fd == -1 && stdout_fd == -1 && stderr_fd == -1 &&
(flags & G_SPAWN_CHILD_INHERITS_STDIN) &&
!(flags & G_SPAWN_STDOUT_TO_DEV_NULL) &&