mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1174046 - Fix PLDHashTable::Iterator in chaos mode again. r=froydnj, a=philor
CLOSED TREE If you use PLDHashTable::Iterator in chaos mode with a table with zero capacity, a |% 0| operation takes place in randomUint32LessThan. This change avoids that.
This commit is contained in:
parent
8127240e63
commit
f5cca86bcb
@ -81,6 +81,7 @@ public:
|
||||
*/
|
||||
static uint32_t randomUint32LessThan(uint32_t aBound)
|
||||
{
|
||||
MOZ_ASSERT(aBound != 0);
|
||||
return uint32_t(rand()) % aBound;
|
||||
}
|
||||
};
|
||||
|
@ -910,7 +910,7 @@ PLDHashTable::Iterator::Iterator(const PLDHashTable* aTable)
|
||||
// mEntryAddr, respectively.
|
||||
uint32_t capacity = mTable->Capacity();
|
||||
|
||||
if (ChaosMode::isActive(ChaosMode::HashTableIteration)) {
|
||||
if (ChaosMode::isActive(ChaosMode::HashTableIteration) && capacity > 0) {
|
||||
// Start iterating at a random point in the hashtable. It would be
|
||||
// even more chaotic to iterate in fully random order, but that's a lot
|
||||
// more work.
|
||||
|
Loading…
Reference in New Issue
Block a user