diff options
Diffstat (limited to 'llvm/lib/Support/Windows/Process.inc')
-rw-r--r-- | llvm/lib/Support/Windows/Process.inc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Support/Windows/Process.inc b/llvm/lib/Support/Windows/Process.inc index 18aef610d54..3fe9f89f1ef 100644 --- a/llvm/lib/Support/Windows/Process.inc +++ b/llvm/lib/Support/Windows/Process.inc @@ -129,9 +129,10 @@ Optional<std::string> Process::GetEnv(StringRef Name) { size_t Size = MAX_PATH; do { Buf.reserve(Size); + SetLastError(NO_ERROR); Size = - GetEnvironmentVariableW(NameUTF16.data(), Buf.data(), Buf.capacity()); - if (Size == 0) + GetEnvironmentVariableW(NameUTF16.data(), Buf.data(), Buf.capacity()); + if (Size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND) return None; // Try again with larger buffer. |