[PATCH] D38570: Support: Rewrite Windows implementation of sys::fs::rename to be more POSIXy.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 9 10:13:03 PDT 2017
grimar added inline comments.
================
Comment at: llvm/trunk/lib/Support/Windows/Path.inc:375
+ RenameInfo.FileNameLength = ToWide.size();
+ std::copy(ToWide.begin(), ToWide.end(), RenameInfo.FileName);
+
----------------
This asserts under windows/debug.
`RenameInfo.FileName` here is `WCHAR FileName[1];` and std::copy checks it's size
for overflow and fails:
```
_Myiter& operator+=(difference_type _Off)
{ // increment by integer
#if _ITERATOR_DEBUG_LEVEL == 2
if (_Size < _Idx + _Off)
{ // report error
_DEBUG_ERROR("array iterator + offset out of range");
_SCL_SECURE_OUT_OF_RANGE;
}
```
```
template<class _InIt,
class _OutTy,
size_t _OutSize> inline
_OutTy *copy(_InIt _First, _InIt _Last,
_OutTy (&_Dest)[_OutSize])
{ // copy [_First, _Last) to [_Dest, ...)
```
I would suggest to use memcpy instead.
Repository:
rL LLVM
https://reviews.llvm.org/D38570
More information about the llvm-commits
mailing list