Просмотр исходного кода

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

Jorrit Rouwe 9 месяцев назад
Родитель
Сommit
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