Buggy code:
public final class MultiTermsEnum extends TermsEnum { private final MultiTermsEnum . TermMergeQueue queue ; private final MultiTermsEnum . TermsEnumWithSlice [ ] subs ; private final MultiTermsEnum . TermsEnumWithSlice [ ] currentSubs ; private final MultiTermsEnum . TermsEnumWithSlice [ ] top ; private final EnumWithSlice [ ] subDocs ; private final MultiDocsAndPositionsEnum . EnumWithSlice [ ] subDocsAndPositions ; private BytesRef lastSeek ; private boolean lastSeekExact ; private final BytesRef lastSeekScratch = new BytesRef ( ) ; private int numTop ; private int numSubs ; private BytesRef current ; private Comparator < BytesRef > termComp ; public static class TermsEnumIndex { public static final MultiTermsEnum . TermsEnumIndex [ ] EMPTY_ARRAY = new MultiTermsEnum . TermsEnumIndex [ 0 ] ; final int subIndex ; final TermsEnum termsEnum ; public TermsEnumIndex ( TermsEnum termsEnum , int subIndex ) { } } public int getMatchCount ( ) { } public MultiTermsEnum . TermsEnumWithSlice [ ] getMatchArray ( ) { } public MultiTermsEnum ( ReaderUtil [ ] slices ) { } @ Override public BytesRef term ( ) { } @ Override public Comparator < BytesRef > getComparator ( ) { } public TermsEnum reset ( MultiTermsEnum . TermsEnumIndex [ ] termsEnumsIndex ) throws IOException { } @ Override public boolean seekExact ( BytesRef term , boolean useCache ) throws IOException { } @ Override public SeekStatus seekCeil ( BytesRef term , boolean useCache ) throws IOException { queue . clear ( ) ; numTop = 0 ; lastSeekExact = false ; boolean seekOpt = false ; if ( ( ( lastSeek ) != null ) && ( ( termComp . compare ( lastSeek , term ) ) <= 0 ) ) { seekOpt = true ; } <START_BUG> lastSeekScratch . copy ( term ) ; <END_BUG> lastSeek = lastSeekScratch ; for ( int i = 0 ; i < ( numSubs ) ; i ++ ) { final SeekStatus status ; if ( seekOpt ) { final BytesRef curTerm = currentSubs [ i ] . current ; if ( curTerm != null ) { final int cmp = termComp . compare ( term , curTerm ) ; if ( cmp == 0 ) { status = SeekStatus . FOUND ; } else if ( cmp < 0 ) { status = SeekStatus . NOT_FOUND ; } else { status = currentSubs [ i ] . terms . seekCeil ( term , useCache ) ; } } else { status = SeekStatus . END ; } } else { status = currentSubs [ i ] . terms . seekCeil ( term , useCache ) ; } if ( status == ( SeekStatus . FOUND ) ) { top [ ( ( numTop ) ++ ) ] = currentSubs [ i ] ; current = currentSubs [ i ] . current = currentSubs [ i ] . terms . term ( ) ; } else { if ( status == ( SeekStatus . NOT_FOUND ) ) { currentSubs [ i ] . current = currentSubs [ i ] . terms . term ( ) ; assert ( currentSubs [ i ] . current ) != null ; queue . add ( currentSubs [ i ] ) ; } else { currentSubs [ i ] . current = null ; } } } if ( ( numTop ) > 0 ) { return SeekStatus . FOUND ; } else if ( ( queue . size ( ) ) > 0 ) { pullTop ( ) ; return SeekStatus . NOT_FOUND ; } else { return SeekStatus . END ; } } @ Override public void seekExact ( long ord ) throws IOException { } @ Override public long ord ( ) throws IOException { } private void pullTop ( ) { } private void pushTop ( ) throws IOException { } @ Override public BytesRef next ( ) throws IOException { } @ Override public int docFreq ( ) throws IOException { } @ Override public long totalTermFreq ( ) throws IOException { } @ Override public DocsEnum docs ( Bits liveDocs , DocsEnum reuse ) throws IOException { } @ Override public DocsAndPositionsEnum docsAndPositions ( Bits liveDocs , DocsAndPositionsEnum reuse ) throws IOException { } private static final class TermsEnumWithSlice { private final Slice subSlice ; private TermsEnum terms ; public BytesRef current ; final int index ; public TermsEnumWithSlice ( int index , ReaderUtil . Slice subSlice ) { } public void reset ( TermsEnum terms , BytesRef term ) { } } private static final class TermMergeQueue extends PriorityQueue < MultiTermsEnum . TermsEnumWithSlice > { Comparator < BytesRef > termComp ; TermMergeQueue ( int size ) { } @ Override protected boolean lessThan ( MultiTermsEnum . TermsEnumWithSlice termsA , MultiTermsEnum . TermsEnumWithSlice termsB ) { } } }

Fix:
lastSeekScratch . copyBytes ( term ) ;