Windows/Process.inc: Fix for +Asserts. &Buf[0] is not guaranteed if size is zero.
authorNAKAMURA Takumi <geek4civic@gmail.com>
Mon, 7 Oct 2013 15:33:30 +0000 (15:33 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Mon, 7 Oct 2013 15:33:30 +0000 (15:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192103 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/Windows/Process.inc

index 4d801492e830a2db1edbea306f8f7678bd150da3..50a204fe5faef5d8959fb6ab07f1bcc9dc7aaeb6 100644 (file)
@@ -161,7 +161,7 @@ Optional<std::string> Process::GetEnv(StringRef Name) {
   SmallVector<wchar_t, MAX_PATH> Buf;
   size_t Size = MAX_PATH;
   do {
-    Buf.reserve(Size);
+    Buf.resize(Size);
     Size = GetEnvironmentVariableW(&NameUTF16[0], &Buf[0], Buf.capacity());
     if (Size == 0)
       return None;