From 4f8195643428c5a991ddcb729945c69d5e73376b Mon Sep 17 00:00:00 2001 From: Mayya Sharipova Date: Wed, 18 Sep 2024 14:36:01 -0400 Subject: [PATCH] Cast to long when multiplyExact to avoid integer overflow --- .../codecs/lucene912/Lucene912BinaryQuantizedVectorsReader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene912/Lucene912BinaryQuantizedVectorsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene912/Lucene912BinaryQuantizedVectorsReader.java index 5e03a678db16..ef3388ba18c7 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene912/Lucene912BinaryQuantizedVectorsReader.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene912/Lucene912BinaryQuantizedVectorsReader.java @@ -140,7 +140,7 @@ static void validateFieldEntry(FieldInfo info, FieldEntry fieldEntry) { int correctionsCount = fieldEntry.similarityFunction != VectorSimilarityFunction.EUCLIDEAN ? 3 : 2; long numQuantizedVectorBytes = - Math.multiplyExact(binaryDims + (Float.BYTES * correctionsCount), fieldEntry.size); + Math.multiplyExact((binaryDims + (Float.BYTES * correctionsCount)), (long) fieldEntry.size); if (numQuantizedVectorBytes != fieldEntry.vectorDataLength) { throw new IllegalStateException( "Binarized vector data length "