diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 202f9eb6a0..5e02bd3d02 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -6427,6 +6427,10 @@ static void fts5DecodeFunction( /* Decode any more doclist data that appears on the page before the ** first term. */ nDoclist = (iTermOff ? iTermOff : szLeaf) - iOff; + if( nDoclist+iOff>n ){ + rc = FTS5_CORRUPT; + goto decode_out; + } fts5DecodeDoclist(&rc, &s, &a[iOff], nDoclist); while( iPgidxOff