RangeArray::AddRange(): Fix joining with single subsequent range
When joining with a single range, firstRange would be the same as RangeAt(endIndex - 1) and we would overwrite its offset field before getting its end offset, thus possibly resulting in a wrong joined range size.
This commit is contained in:
parent
2be66b5125
commit
06064b9b4f
@ -142,10 +142,10 @@ RangeArray<Value>::AddRange(const Value& offset, const Value& size)
|
||||
|
||||
// Joining is possible. We'll adjust the first affected range and remove the
|
||||
// others (if any).
|
||||
endOffset = std::max(endOffset, RangeAt(endIndex - 1).EndOffset());
|
||||
RangeType& firstRange = _RangeAt(index);
|
||||
firstRange.offset = std::min(firstRange.offset, offset);
|
||||
firstRange.size = std::max(endOffset, RangeAt(endIndex - 1).EndOffset())
|
||||
- firstRange.offset;;
|
||||
firstRange.size = endOffset - firstRange.offset;
|
||||
|
||||
if (index + 1 < endIndex)
|
||||
RemoveRanges(index + 1, endIndex - index - 1);
|
||||
|
Loading…
Reference in New Issue
Block a user