Bug 1730534 - Part 1: Assert state of SegmentedVector iterator is valid r=mccr8

The next patches remove elements from a segmented vector that is being
iterated. This patch adds assertions to ensure that we don't attempt to use an
iterator that points to a removed element.

The assertions are added to Done() because all the other methods call that.

Differential Revision: https://phabricator.services.mozilla.com/D125426
This commit is contained in:
Jon Coppeard 2021-09-27 16:41:51 +00:00
Родитель c11679da97
Коммит 4055d681e6
1 изменённых файлов: 5 добавлений и 1 удалений

Просмотреть файл

@ -289,7 +289,11 @@ class SegmentedVector : private AllocPolicy {
}
public:
bool Done() const { return !mSegment; }
bool Done() const {
MOZ_ASSERT_IF(mSegment, mSegment->isInList());
MOZ_ASSERT_IF(mSegment, mIndex < mSegment->Length());
return !mSegment;
}
T& Get() {
MOZ_ASSERT(!Done());