未验证 提交 96d7d903 编写于 作者: E Egor Bogatov 提交者: GitHub

Fix div-by-zero introduced in https://github.com/dotnet/runtime/pull/65926 (#66035)

上级 a7a4ed95
......@@ -198,7 +198,7 @@ BOOL EEHashTableBase<KeyType, Helper, bDefaultCopyIsDeep>::Init(DWORD dwNumBucke
m_pVolatileBucketTable->m_pBuckets++;
m_pVolatileBucketTable->m_dwNumBuckets = dwNumBuckets;
#ifdef TARGET_64BIT
m_pVolatileBucketTable->m_dwNumBucketsMul = GetFastModMultiplier(dwNumBuckets);
m_pVolatileBucketTable->m_dwNumBucketsMul = dwNumBuckets == 0 ? 0 : GetFastModMultiplier(dwNumBuckets);
#endif
m_Heap = pHeap;
......@@ -786,7 +786,7 @@ BOOL EEHashTableBase<KeyType, Helper, bDefaultCopyIsDeep>::GrowHashTable()
pNewBucketTable->m_pBuckets = pNewBuckets;
pNewBucketTable->m_dwNumBuckets = dwNewNumBuckets;
#ifdef TARGET_64BIT
pNewBucketTable->m_dwNumBucketsMul = GetFastModMultiplier(dwNewNumBuckets);
pNewBucketTable->m_dwNumBucketsMul = dwNewNumBuckets == 0 ? 0 : GetFastModMultiplier(dwNewNumBuckets);
#endif
// Add old table to the to free list. Note that the SyncClean thing will only
......
......@@ -1017,7 +1017,10 @@ inline UINT64 GetFastModMultiplier(UINT32 divisor)
inline UINT32 FastMod(UINT32 value, UINT32 divisor, UINT64 multiplier)
{
return (UINT32)(((((multiplier * value) >> 32) + 1) * divisor) >> 32);
_ASSERTE(divisor <= INT_MAX);
UINT32 highbits = (UINT32)(((((multiplier * value) >> 32) + 1) * divisor) >> 32);
_ASSERTE(highbits == value % divisor);
return highbits;
}
#endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册