LUCENE-6910: fix 'if ... > Integer.MAX_VALUE' check in (Binary|Numeric)DocValuesFieldUpdates.merge (https://scan.coverity.com/projects/5620 CID 119973 and CID 120081)

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1717993 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Christine Poerschke 2015-12-04 16:45:14 +00:00
parent 30c0cfc262
commit 3799ea6027
3 changed files with 8 additions and 3 deletions

View File

@ -124,6 +124,11 @@ Bug Fixes
* LUCENE-6918: LRUQueryCache.onDocIdSetEviction is only called when at least
one DocIdSet is being evicted. (Adrien Grand)
* LUCENE-6910: fix 'if ... > Integer.MAX_VALUE' check in
(Binary|Numeric)DocValuesFieldUpdates.merge
(https://scan.coverity.com/projects/5620 CID 119973 and CID 120081)
(Christine Poerschke, Coverity Scan (via Rishabh Patel))
======================= Lucene 5.4.0 =======================
New Features

View File

@ -169,12 +169,12 @@ class BinaryDocValuesFieldUpdates extends DocValuesFieldUpdates {
@Override
public void merge(DocValuesFieldUpdates other) {
BinaryDocValuesFieldUpdates otherUpdates = (BinaryDocValuesFieldUpdates) other;
int newSize = size + otherUpdates.size;
if (newSize > Integer.MAX_VALUE) {
if (otherUpdates.size > Integer.MAX_VALUE - size) {
throw new IllegalStateException(
"cannot support more than Integer.MAX_VALUE doc/value entries; size="
+ size + " other.size=" + otherUpdates.size);
}
final int newSize = size + otherUpdates.size;
docs = docs.grow(newSize);
offsets = offsets.grow(newSize);
lengths = lengths.grow(newSize);

View File

@ -144,7 +144,7 @@ class NumericDocValuesFieldUpdates extends DocValuesFieldUpdates {
public void merge(DocValuesFieldUpdates other) {
assert other instanceof NumericDocValuesFieldUpdates;
NumericDocValuesFieldUpdates otherUpdates = (NumericDocValuesFieldUpdates) other;
if (size + otherUpdates.size > Integer.MAX_VALUE) {
if (otherUpdates.size > Integer.MAX_VALUE - size) {
throw new IllegalStateException(
"cannot support more than Integer.MAX_VALUE doc/value entries; size="
+ size + " other.size=" + otherUpdates.size);