[all-commits] [llvm/llvm-project] ceffd6: [Support][Windows] Fix incorrect GetFinalPathNameB...
Aleksandr Platonov via All-commits
all-commits at lists.llvm.org
Wed Aug 26 12:12:44 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: ceffd6993c350b57f43cec3b6371b159fc4a3149
https://github.com/llvm/llvm-project/commit/ceffd6993c350b57f43cec3b6371b159fc4a3149
Author: Aleksandr Platonov <platonov.aleksandr at huawei.com>
Date: 2020-08-26 (Wed, 26 Aug 2020)
Changed paths:
M llvm/lib/Support/Windows/Path.inc
Log Message:
-----------
[Support][Windows] Fix incorrect GetFinalPathNameByHandleW() return value check in realPathFromHandle()
`GetFinalPathNameByHandleW(,,N,)` returns:
- `< N` on success (this value does not include the size of the terminating null character)
- `>= N` if buffer is too small (this value includes the size of the terminating null character)
So, when `N == Buffer.capacity() - 1`, we need to resize buffer if return value is > `Buffer.capacity() - 2`.
Also, we can set `N` to `Buffer.capacity()`.
Thus, without this patch `realPathFromHandle()` returns unfilled buffer when length of the final path of the file is equal to `Buffer.capacity()` or `Buffer.capacity() - 1`.
Reviewed By: andrewng, amccarth
Differential Revision: https://reviews.llvm.org/D86564
More information about the All-commits
mailing list