Skip to content

Commit

Permalink
Cast to long when multiplyExact to avoid integer overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mayya-sharipova committed Sep 18, 2024
1 parent 3acf852 commit 4f81956
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down

0 comments on commit 4f81956

Please sign in to comment.