Bug 1362761 - Safer Clean() and IsEmpty() handling in PrefixSet. r=dimi

This simplifies the logic around clearing the prefix set and also adds
the clearing of the mIndexDeltasChecksum which should have been done
as part of 3a00711bb0e6.

Additionally, the checks for whether or not the prefix set is empty
include some sanity-checking asserts.

Finally, mTotalPrefixes could be out of sync with mIndexPrefixes
and mIndexDeltas if LoadPrefixes() or MakePrefixSet() fail so we
now only update it once all elements have been added successfully.

There is now a release assert to catch grossly out-of-sync (or
corrupt) values of mTotalPrefixes.

MozReview-Commit-ID: BSbyD2dGsUY

Differential Revision: https://phabricator.services.mozilla.com/D2062
This commit is contained in:
Francois Marier
2018-07-11 12:40:34 +00:00
parent 8e84aa521c
commit 6f7879d6d8
3 changed files with 30 additions and 15 deletions

View File

@@ -98,6 +98,7 @@ VariableLengthPrefixSet::SetPrefixes(const PrefixStringMap& aPrefixMap)
array.AppendElement(BigEndian::readUint32(begin), fallible);
begin += sizeof(uint32_t);
}
MOZ_ASSERT(array.Length() == numPrefixes);
const uint32_t* arrayPtr = array.Elements();
#endif