Bug 1174046 - Fix PLDHashTable::Iterator in chaos mode again. r=froydnj.

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.

--HG--
extra : rebase_source : 85f2affb57c2402f40f3d117434b8300e7f204b7
This commit is contained in:
Nicholas Nethercote 2015-06-11 18:23:26 -07:00
Родитель 10246c32dc
Коммит d2a5b36906
2 изменённых файлов: 2 добавлений и 1 удалений

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

@ -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.