From: Ron Yorston Subject: msvcrt: Fix passing of explicit environment to spawn/exec calls Message-Id: <54760de4.4HLUTGBBliPfnhhc%rmy@tigress.co.uk> Date: Wed, 26 Nov 2014 17:29:08 +0000 Explicit sets of environment variables passed to spawn/exec are consistently converted to wide character environment blocks. Because CREATE_UNICODE_ENVIRONMENT isn't included in the process creation flags the environment block is incorrectly passed through another conversion to wide characters in create_process_impl. --- dlls/msvcrt/process.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dlls/msvcrt/process.c b/dlls/msvcrt/process.c index b782727..9ff7dba 100644 --- a/dlls/msvcrt/process.c +++ b/dlls/msvcrt/process.c @@ -134,6 +134,7 @@ static MSVCRT_intptr_t msvcrt_spawn(int flags, const MSVCRT_wchar_t* exe, MSVCRT STARTUPINFOW si; PROCESS_INFORMATION pi; MSVCRT_wchar_t fullname[MAX_PATH]; + DWORD flg; TRACE("%x %s %s %s %d\n", flags, debugstr_w(exe), debugstr_w(cmdline), debugstr_w(env), use_path); @@ -148,8 +149,9 @@ static MSVCRT_intptr_t msvcrt_spawn(int flags, const MSVCRT_wchar_t* exe, MSVCRT memset(&si, 0, sizeof(si)); si.cb = sizeof(si); msvcrt_create_io_inherit_block(&si.cbReserved2, &si.lpReserved2); - if (!CreateProcessW(fullname, cmdline, NULL, NULL, TRUE, - flags == MSVCRT__P_DETACH ? DETACHED_PROCESS : 0, + flg = flags == MSVCRT__P_DETACH ? DETACHED_PROCESS : 0; + flg |= env ? CREATE_UNICODE_ENVIRONMENT : 0; + if (!CreateProcessW(fullname, cmdline, NULL, NULL, TRUE, flg, env, NULL, &si, &pi)) { msvcrt_set_errno(GetLastError()); -- 1.7.1