diff --git a/win32/win32.c b/win32/win32.c index f19c097..d292425 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1117,6 +1117,7 @@ CreateChild(const WCHAR *cmd, const WCHAR *prog, SECURITY_ATTRIBUTES *psa, PROCESS_INFORMATION aProcessInformation; SECURITY_ATTRIBUTES sa; struct ChildRecord *child; + WCHAR tmpCmd[MAX_PATH * 2]; if (!cmd && !prog) { errno = EFAULT; @@ -1167,8 +1168,11 @@ CreateChild(const WCHAR *cmd, const WCHAR *prog, SECURITY_ATTRIBUTES *psa, return NULL; } + /* Make a copy of cmd so CreateProcessW() can modify it if it needs to. */ + _tcscpy_s(tmpCmd, MAX_PATH *2, (WCHAR *)cmd); + RUBY_CRITICAL({ - fRet = CreateProcessW(prog, (WCHAR *)cmd, psa, psa, + fRet = CreateProcessW(prog, tmpCmd, psa, psa, psa->bInheritHandle, dwCreationFlags, NULL, NULL, &aStartupInfo, &aProcessInformation); errno = map_errno(GetLastError());