Skip to content

Commit

Permalink
Fix integer overflow in SortedRanges.subRangeByPos. Fixes #664 (#665)
Browse files Browse the repository at this point in the history
Co-authored-by: Cristian Ferretti <cristianferretti@illumon.com>
  • Loading branch information
jcferretti and Cristian Ferretti authored May 24, 2021
1 parent 23a31a9 commit 8f88e2b
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8f88e2b

Please sign in to comment.