Commit e8f2c246 authored by Martin Storsjo's avatar Martin Storsjo Committed by Alexandre Julliard

ntdll: Only call putenv() if we are going to call exec().

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: 's avatarMartin Storsjo <martin@martin.st> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 2306efc3
......@@ -1685,14 +1685,14 @@ 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";
char **new_argv = malloc( (argc + 2) * sizeof(*argv) );
memcpy( new_argv + 1, argv, (argc + 1) * sizeof(*argv) );
putenv( noexec );
loader_exec( argv0, new_argv, client_cpu );
fatal_error( "could not exec the wine loader\n" );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment