浏览代码

Bugfix: HashTable had an integer overflow when the number of elements was very large

Jorrit Rouwe 9 月之前
父节点
当前提交
e18aa8b300
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      Jolt/Core/HashTable.h

+ 1 - 1
Jolt/Core/HashTable.h

@@ -119,7 +119,7 @@ private:
 
 		mMaxSize = inMaxSize;
 		mMaxLoad = uint32((cMaxLoadFactorNumerator * inMaxSize) / cMaxLoadFactorDenominator);
-		size_type required_size = mMaxSize * (sizeof(KeyValue) + 1) + 15; // Add 15 bytes to mirror the first 15 bytes of the control values
+		size_t required_size = size_t(mMaxSize) * (sizeof(KeyValue) + 1) + 15; // Add 15 bytes to mirror the first 15 bytes of the control values
 		if constexpr (cNeedsAlignedAllocate)
 			mData = reinterpret_cast<KeyValue *>(AlignedAllocate(required_size, alignof(KeyValue)));
 		else