mirror of https://github.com/apache/lucene.git
LUCENE-3876: don't corrupt the index (from wrong shift operator) for large documents
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1301466 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f779f83a95
commit
4f37e0f341
|
@ -943,6 +943,10 @@ Bug fixes
|
|||
integer overflow. This can happen, for example when using a buggy
|
||||
TokenStream that forgets to call clearAttributes() in combination
|
||||
with a StopFilter. (Robert Muir)
|
||||
|
||||
* LUCENE-3876: Fix bug where positions for a document exceeding
|
||||
Integer.MAX_VALUE/2 would produce a corrupt index.
|
||||
(Simon Willnauer, Mike Mccandless, Robert Muir)
|
||||
|
||||
Optimizations
|
||||
|
||||
|
|
|
@ -486,7 +486,7 @@ final class FreqProxTermsWriterPerField extends TermsHashConsumerPerField implem
|
|||
|
||||
if (readPositions) {
|
||||
final int code = prox.readVInt();
|
||||
position += code >> 1;
|
||||
position += code >>> 1;
|
||||
|
||||
if ((code & 1) != 0) {
|
||||
|
||||
|
|
|
@ -1517,4 +1517,20 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
|
|||
iw.close();
|
||||
dir.close();
|
||||
}
|
||||
|
||||
public void testLegalbutVeryLargePositions() throws Exception {
|
||||
Directory dir = newDirectory();
|
||||
IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, null));
|
||||
Document doc = new Document();
|
||||
Token t1 = new Token("foo", 0, 3);
|
||||
t1.setPositionIncrement(Integer.MAX_VALUE-500);
|
||||
TokenStream overflowingTokenStream = new CannedTokenStream(
|
||||
new Token[] { t1 }
|
||||
);
|
||||
Field field = new TextField("foo", overflowingTokenStream);
|
||||
doc.add(field);
|
||||
iw.addDocument(doc);
|
||||
iw.close();
|
||||
dir.close();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue