Commit 343f535
committed
Fix integer underflow in assertion in SparseFixedBitSet (#16347)
For values close to Integer.MAX_VALUE, the blockCount calculation in
SparseFixedBitSet can result in an assertion tripping. The method
checks that the calculated block count will cover the full length
of the bitset; if the block count covers the whole integer range,
the check will underflow to a negative value, which compares as
smaller than the passed-in length. This is fixed by a simple cast
to long.
Note that the error is only in the assertion; the actual calculated
block count is correct and there is no production bug.1 parent 17cb091 commit 343f535
2 files changed
Lines changed: 6 additions & 2 deletions
File tree
- lucene/core/src
- java/org/apache/lucene/util
- test/org/apache/lucene/util
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
158 | 162 | | |
0 commit comments