Bug 1592325 - Fix an unsigned-integer underflow in HashTable.h that's super-easy to trigger using affirmatively wrapping operations. r=froydnj

Differential Revision: https://phabricator.services.mozilla.com/D50960

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jeff Walden 2019-10-29 16:42:15 +00:00
parent 1ed947aff2
commit 7d74f15a31

View File

@ -90,6 +90,7 @@
#include "mozilla/ReentrancyGuard.h"
#include "mozilla/TypeTraits.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/WrappingOperations.h"
namespace mozilla {
@ -1700,7 +1701,7 @@ class HashTable : private AllocPolicy {
static HashNumber applyDoubleHash(HashNumber aHash1,
const DoubleHash& aDoubleHash) {
return (aHash1 - aDoubleHash.mHash2) & aDoubleHash.mSizeMask;
return WrappingSubtract(aHash1, aDoubleHash.mHash2) & aDoubleHash.mSizeMask;
}
static MOZ_ALWAYS_INLINE bool match(T& aEntry, const Lookup& aLookup) {