mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-24 16:17:29 +09:00
Bug 1462912 - Fixed BufferList::Extract to handle the case where the call consumes the entirety of the BufferList. r=froydnj, a=RyanVM
This commit is contained in:
parent
921ff8f640
commit
57b3983e17
2 changed files with 20 additions and 1 deletions
|
|
@ -532,7 +532,14 @@ BufferList<AllocPolicy>::Extract(IterImpl& aIter, size_t aSize, bool* aSuccess)
|
||||||
mSegments[aIter.mSegment].mCapacity));
|
mSegments[aIter.mSegment].mCapacity));
|
||||||
aIter.Advance(*this, aIter.RemainingInSegment());
|
aIter.Advance(*this, aIter.RemainingInSegment());
|
||||||
}
|
}
|
||||||
MOZ_RELEASE_ASSERT(aIter.mSegment == copyStart + segmentsToCopy);
|
// Due to the way IterImpl works, there are two cases here: (1) if we've
|
||||||
|
// consumed the entirety of the BufferList, then the iterator is pointed at
|
||||||
|
// the end of the final segment, (2) otherwise it is pointed at the start
|
||||||
|
// of the next segment. We want to verify that we really consumed all
|
||||||
|
// |segmentsToCopy| segments.
|
||||||
|
MOZ_RELEASE_ASSERT(
|
||||||
|
(aIter.mSegment == copyStart + segmentsToCopy) ||
|
||||||
|
(aIter.Done() && aIter.mSegment == copyStart + segmentsToCopy - 1));
|
||||||
mSegments.erase(mSegments.begin() + copyStart,
|
mSegments.erase(mSegments.begin() + copyStart,
|
||||||
mSegments.begin() + copyStart + segmentsToCopy);
|
mSegments.begin() + copyStart + segmentsToCopy);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -279,5 +279,17 @@ int main(void)
|
||||||
MOZ_RELEASE_ASSERT(bl9.Size() == 8);
|
MOZ_RELEASE_ASSERT(bl9.Size() == 8);
|
||||||
MOZ_RELEASE_ASSERT(!iter.Done());
|
MOZ_RELEASE_ASSERT(!iter.Done());
|
||||||
|
|
||||||
|
BufferList bl10(0, 0, 8);
|
||||||
|
bl10.WriteBytes("abcdefgh", 8);
|
||||||
|
bl10.WriteBytes("12345678", 8);
|
||||||
|
iter = bl10.Iter();
|
||||||
|
BufferList bl11 = bl10.Extract(iter, 16, &success);
|
||||||
|
MOZ_RELEASE_ASSERT(success);
|
||||||
|
MOZ_RELEASE_ASSERT(bl11.Size() == 16);
|
||||||
|
MOZ_RELEASE_ASSERT(iter.Done());
|
||||||
|
iter = bl11.Iter();
|
||||||
|
MOZ_RELEASE_ASSERT(bl11.ReadBytes(iter, data, 16));
|
||||||
|
MOZ_RELEASE_ASSERT(memcmp(data, "abcdefgh12345678", 16) == 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue