File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change 19
19
#include " llvm/Support/ConvertUTF.h"
20
20
#include " llvm/Support/WindowsError.h"
21
21
#include < fcntl.h>
22
- #include < io.h>
23
22
#include < sys/stat.h>
24
23
#include < sys/types.h>
25
24
@@ -352,13 +351,13 @@ std::error_code is_local(const Twine &path, bool &result) {
352
351
static std::error_code realPathFromHandle (HANDLE H,
353
352
SmallVectorImpl<wchar_t > &Buffer) {
354
353
DWORD CountChars = ::GetFinalPathNameByHandleW (
355
- H, Buffer.begin (), Buffer.capacity () - 1 , FILE_NAME_NORMALIZED);
356
- if (CountChars > Buffer.capacity ()) {
354
+ H, Buffer.begin (), Buffer.capacity (), FILE_NAME_NORMALIZED);
355
+ if (CountChars && CountChars >= Buffer.capacity ()) {
357
356
// The buffer wasn't big enough, try again. In this case the return value
358
357
// *does* indicate the size of the null terminator.
359
358
Buffer.reserve (CountChars);
360
359
CountChars = ::GetFinalPathNameByHandleW (
361
- H, Buffer.data (), Buffer.capacity () - 1 , FILE_NAME_NORMALIZED);
360
+ H, Buffer.begin (), Buffer.capacity (), FILE_NAME_NORMALIZED);
362
361
}
363
362
if (CountChars == 0 )
364
363
return mapWindowsError (GetLastError ());
You can’t perform that action at this time.
0 commit comments