From 206480992dffa2053cb4818b1a4f6da8e2c1ebf6 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 22 Apr 2015 20:58:24 +0000 Subject: [PATCH] Add extra OOM tests for fts5. FossilOrigin-Name: 2dd59b5762c944b3bdd270e95c6739cd4f530bfa --- ext/fts5/fts5_expr.c | 5 ++-- ext/fts5/fts5_index.c | 15 ++-------- ext/fts5/test/fts5fault2.test | 55 +++++++++++++++++++++++++++++++++++ manifest | 15 +++++----- manifest.uuid | 2 +- 5 files changed, 70 insertions(+), 22 deletions(-) create mode 100644 ext/fts5/test/fts5fault2.test diff --git a/ext/fts5/fts5_expr.c b/ext/fts5/fts5_expr.c index 878b54f53e..af44bcf760 100644 --- a/ext/fts5/fts5_expr.c +++ b/ext/fts5/fts5_expr.c @@ -623,8 +623,9 @@ static int fts5ExprAdvanceto( iRowid = sqlite3Fts5IterRowid(pIter); if( (bDesc==0 && iLast>iRowid) || (bDesc && iLastrc==SQLITE_OK ){ + const u8 *a = &pIter->pLeaf->p[pIter->iLeafOffset]; int iOff = pIter->iLeafOffset; /* Offset to read at */ - if( iOff>=pIter->pLeaf->n ){ - assert( 0 ); - fts5SegIterNextPage(p, pIter); - if( pIter->pLeaf==0 ){ - if( p->rc==SQLITE_OK ) p->rc = FTS5_CORRUPT; - return; - } - iOff = 4; - } - iOff += fts5GetPoslistSize(pIter->pLeaf->p+iOff, &pIter->nPos,&pIter->bDel); - pIter->iLeafOffset = iOff; + pIter->iLeafOffset += fts5GetPoslistSize(a, &pIter->nPos,&pIter->bDel); } } @@ -1678,7 +1669,7 @@ static void fts5SegIterReverseInitPage(Fts5Index *p, Fts5SegIter *pIter){ u8 *a = pIter->pLeaf->p; int iRowidOffset = 0; - while( p->rc==SQLITE_OK && i