aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/Windows/Process.inc
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Support/Windows/Process.inc')
-rw-r--r--llvm/lib/Support/Windows/Process.inc8
1 files changed, 4 insertions, 4 deletions
diff --git a/llvm/lib/Support/Windows/Process.inc b/llvm/lib/Support/Windows/Process.inc
index 6732063b562e..dfaab1613de1 100644
--- a/llvm/lib/Support/Windows/Process.inc
+++ b/llvm/lib/Support/Windows/Process.inc
@@ -129,16 +129,16 @@ Optional<std::string> Process::GetEnv(StringRef Name) {
SmallVector<wchar_t, MAX_PATH> Buf;
size_t Size = MAX_PATH;
do {
- Buf.reserve(Size);
+ Buf.resize_for_overwrite(Size);
SetLastError(NO_ERROR);
Size =
- GetEnvironmentVariableW(NameUTF16.data(), Buf.data(), Buf.capacity());
+ GetEnvironmentVariableW(NameUTF16.data(), Buf.data(), Buf.size());
if (Size == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)
return None;
// Try again with larger buffer.
- } while (Size > Buf.capacity());
- Buf.set_size(Size);
+ } while (Size > Buf.size());
+ Buf.truncate(Size);
// Convert the result from UTF-16 to UTF-8.
SmallVector<char, MAX_PATH> Res;