summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgit apple-llvm automerger <am@git-apple-llvm>2020-12-15 16:46:44 -0800
committergit apple-llvm automerger <am@git-apple-llvm>2020-12-15 18:23:10 -0500
commit6af90fed511cd3ade7f20fa58cc5360ecb4c004d (patch)
treefc7a05c441e06b2429e2dc4c95025dbaa2b11957
parent58e662cb61e7b237dd99fe619aa3e3e6154fcd0a (diff)
parentf684355e0292b8e24a0870ecfda126fb15c9eb93 (diff)
downloadllvm-6af90fed511cd3ade7f20fa58cc5360ecb4c004d.tar.gz
Merge commit 'f684355e0292' from llvm.org/release/11.x into apple/stable/20200714
-rw-r--r--llvm/lib/Support/Windows/Path.inc7
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc
index e352beb77616..365ab01c0a16 100644
--- a/llvm/lib/Support/Windows/Path.inc
+++ b/llvm/lib/Support/Windows/Path.inc
@@ -19,7 +19,6 @@
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/WindowsError.h"
#include <fcntl.h>
-#include <io.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -352,13 +351,13 @@ std::error_code is_local(const Twine &path, bool &result) {
static std::error_code realPathFromHandle(HANDLE H,
SmallVectorImpl<wchar_t> &Buffer) {
DWORD CountChars = ::GetFinalPathNameByHandleW(
- H, Buffer.begin(), Buffer.capacity() - 1, FILE_NAME_NORMALIZED);
- if (CountChars > Buffer.capacity()) {
+ H, Buffer.begin(), Buffer.capacity(), FILE_NAME_NORMALIZED);
+ if (CountChars && CountChars >= Buffer.capacity()) {
// The buffer wasn't big enough, try again. In this case the return value
// *does* indicate the size of the null terminator.
Buffer.reserve(CountChars);
CountChars = ::GetFinalPathNameByHandleW(
- H, Buffer.data(), Buffer.capacity() - 1, FILE_NAME_NORMALIZED);
+ H, Buffer.begin(), Buffer.capacity(), FILE_NAME_NORMALIZED);
}
if (CountChars == 0)
return mapWindowsError(GetLastError());