diff --git a/winpr/libwinpr/thread/process.c b/winpr/libwinpr/thread/process.c index 475b14c8b..fca03dd2f 100644 --- a/winpr/libwinpr/thread/process.c +++ b/winpr/libwinpr/thread/process.c @@ -241,7 +241,7 @@ BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, else { lpszEnvironmentBlock = GetEnvironmentStrings(); - if (lpszEnvironmentBlock) + if (!lpszEnvironmentBlock) goto finish; envp = EnvironmentBlockToEnvpA(lpszEnvironmentBlock); } @@ -317,11 +317,12 @@ BOOL _CreateProcessExA(HANDLE hToken, DWORD dwLogonFlags, if (token->UserId) setuid((uid_t) token->UserId); - /* TODO: add better cwd handling and error checking */ - if (lpCurrentDirectory && strlen(lpCurrentDirectory) > 0) - chdir(lpCurrentDirectory); } + /* TODO: add better cwd handling and error checking */ + if (lpCurrentDirectory && strlen(lpCurrentDirectory) > 0) + chdir(lpCurrentDirectory); + if (execve(filename, pArgs, envp) < 0) { /* execve failed - end the process */