I noticed this when working on LUCENE-5977.
We only check that position doesn't overflow, not length. So a buggy analyzer can happily write a corrupt index (negative freq)
Patch with a simple check. The test is marked Nightly, it takes about 2 minutes.
Commit 1629835 from Robert Muir in branch 'dev/trunk'
[ https://svn.apache.org/r1629835 ]
LUCENE-5980: don't let document length overflow
Commit 1629836 from Robert Muir in branch 'dev/branches/branch_5x'
[ https://svn.apache.org/r1629836 ]
reopen for backport
Commit 1642623 from Robert Muir in branch 'dev/branches/lucene_solr_4_10'
[ https://svn.apache.org/r1642623 ]
LUCENE-5980: Don't let document length overflow.
Bulk close after 5.0 release.