If we aren't going to exec (if pre_exec() returns zero), we will continue using the envp pointer we got from the caller. However, the putenv() call does update the environment, and this can in some cases overwrite the array that the old (stale, potentially dangling) envp pointer points to.
Signed-off-by: Martin Storsjo martin@martin.st --- dlls/ntdll/unix/loader.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index d621d4ef8e..47d9ebe684 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -1685,12 +1685,13 @@ void __wine_main( int argc, char *argv[], char *envp[] )
if (!getenv( "WINELOADERNOEXEC" )) /* first time around */ { - static char noexec[] = "WINELOADERNOEXEC=1"; - - putenv( noexec ); check_command_line( argc, argv ); if (pre_exec()) { + static char noexec[] = "WINELOADERNOEXEC=1"; + + putenv( noexec ); + char **new_argv = malloc( (argc + 2) * sizeof(*argv) ); memcpy( new_argv + 1, argv, (argc + 1) * sizeof(*argv) ); loader_exec( argv0, new_argv, client_cpu );