From e0a8e50dedf7f51d59a7182def9ca976de59e78b Mon Sep 17 00:00:00 2001 From: Cristian Ferretti Date: Mon, 24 May 2021 16:26:42 -0400 Subject: [PATCH] Fix integer overflow in SortedRanges.subRangeByPos. Fixes #664 --- .../io/deephaven/db/v2/utils/sortedranges/SortedRanges.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DB/src/main/java/io/deephaven/db/v2/utils/sortedranges/SortedRanges.java b/DB/src/main/java/io/deephaven/db/v2/utils/sortedranges/SortedRanges.java index f367c9b2448..62253a2f13e 100644 --- a/DB/src/main/java/io/deephaven/db/v2/utils/sortedranges/SortedRanges.java +++ b/DB/src/main/java/io/deephaven/db/v2/utils/sortedranges/SortedRanges.java @@ -1040,7 +1040,7 @@ public final SortedRanges subRangesByPos(final long startPosIn, final long endPo // We don't want to do two passes, we allocated an array big enough instead. final boolean brokenInitialRange = startPos < pos; int ansLen = count - i + (brokenInitialRange ? 2 : 1); - ansLen = Math.min(ansLen, (int) (inputRangeSpan + 1)); + ansLen = (int) Math.min(ansLen, (inputRangeSpan + 1)); final SortedRanges ans = makeMyTypeAndOffset(ansLen); ans.count = 0; ans.cardinality = 0;