forked from Mirrors/openclonk
Fix self-overwrite in C4ValueArray::SetSlice (#1212: Array manipulation goes wrong )
parent
1213a2eef5
commit
8e7001ba0f
|
@ -347,7 +347,10 @@ void C4ValueArray::SetSlice(int32_t startIndex, int32_t endIndex, const C4Value
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the data
|
// Copy the data
|
||||||
for(i = startIndex, j = 0; i < iNewEnd; ++i, ++j)
|
// Since pnData and pData can be the same, we can not copy with
|
||||||
|
//for(i = startIndex, j = 0; i < iNewEnd; ++i, ++j)
|
||||||
|
// but have to start from the end of the copied sequence. That works, since j <= i
|
||||||
|
for(i = iNewEnd - 1, j = iNewEnd - startIndex - 1; i >= startIndex; --i, --j)
|
||||||
{
|
{
|
||||||
assert(j < iOtherSize);
|
assert(j < iOtherSize);
|
||||||
pnData[i] = Other.pData[j];
|
pnData[i] = Other.pData[j];
|
||||||
|
|
Loading…
Reference in New Issue