diff --git a/renderdoc/os/win32/win32_process.cpp b/renderdoc/os/win32/win32_process.cpp index aace1964c..be1f25dcb 100644 --- a/renderdoc/os/win32/win32_process.cpp +++ b/renderdoc/os/win32/win32_process.cpp @@ -157,9 +157,16 @@ void Process::ApplyEnvironmentModification() const char *Process::GetEnvVariable(const char *name) { + DWORD ret = GetEnvironmentVariableA(name, NULL, 0); + if(ret == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND) + return NULL; + static char buf[1024] = {}; - size_t reqSize = 1024; - getenv_s(&reqSize, buf, name); + if(ret >= 1024) + RDCERR("Static buffer insufficiently sized"); + + RDCEraseEl(buf); + GetEnvironmentVariableA(name, buf, RDCMIN((DWORD)1023U, ret)); return buf; }