Explorar o código

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

Jorrit Rouwe hai 8 meses
pai
achega
e18aa8b300
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  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