From: dan Date: Wed, 8 Jan 2025 15:54:44 +0000 (+0000) Subject: Fix a crash in fts5 that could occur if shadow tables are modified or removed. X-Git-Tag: major-relase~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ad460db7eb21cbcdd4f509653f86acbcf43029dc;p=thirdparty%2Fsqlite.git Fix a crash in fts5 that could occur if shadow tables are modified or removed. FossilOrigin-Name: c0b691095ae72fc07530777ef6d23688fb4196ce2e0feff14fc3c597c572252d --- diff --git a/ext/fts5/fts5_index.c b/ext/fts5/fts5_index.c index 242258af70..2e512fd215 100644 --- a/ext/fts5/fts5_index.c +++ b/ext/fts5/fts5_index.c @@ -891,9 +891,13 @@ static int fts5IndexPrepareStmt( ){ if( p->rc==SQLITE_OK ){ if( zSql ){ - p->rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1, + int rc = sqlite3_prepare_v3(p->pConfig->db, zSql, -1, SQLITE_PREPARE_PERSISTENT|SQLITE_PREPARE_NO_VTAB, ppStmt, 0); + /* If this prepare() call fails with SQLITE_ERROR, then one of the + ** %_idx or %_data tables has been removed or modified. Call this + ** corruption. */ + p->rc = (rc==SQLITE_ERROR ? SQLITE_CORRUPT : rc); }else{ p->rc = SQLITE_NOMEM; } diff --git a/ext/fts5/fts5_storage.c b/ext/fts5/fts5_storage.c index 31f5fc5dc3..2b43016bef 100644 --- a/ext/fts5/fts5_storage.c +++ b/ext/fts5/fts5_storage.c @@ -205,6 +205,11 @@ static int fts5StorageGetStmt( if( rc!=SQLITE_OK && pzErrMsg ){ *pzErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(pC->db)); } + if( rc==SQLITE_ERROR && eStmt>FTS5_STMT_LOOKUP2 && eStmt