/ Check-in [2d7b1d1d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a segfault in fts3 prompted by a corrupted database.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2d7b1d1d41ff69d5465fcb861420816ecb066c25a9015eefdab5fae15a2e1c9f
User & Date: dan 2019-01-11 21:34:25
Context
2019-01-11
23:08
Use 64-bit APIs in the fileio.c extension. check-in: b49d56a0 user: drh tags: trunk
21:34
Fix a segfault in fts3 prompted by a corrupted database. check-in: 2d7b1d1d user: dan tags: trunk
19:27
Fix another problem with corrupt databases in fts5. check-in: 9bf811ea user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts3/fts3.c.

  2895   2895         sqlite3_int64 iLeavesEndBlock = sqlite3_column_int64(pStmt, 2);
  2896   2896         sqlite3_int64 iEndBlock = sqlite3_column_int64(pStmt, 3);
  2897   2897         int nRoot = sqlite3_column_bytes(pStmt, 4);
  2898   2898         char const *zRoot = sqlite3_column_blob(pStmt, 4);
  2899   2899   
  2900   2900         /* If zTerm is not NULL, and this segment is not stored entirely on its
  2901   2901         ** root node, the range of leaves scanned can be reduced. Do this. */
  2902         -      if( iStartBlock && zTerm ){
         2902  +      if( iStartBlock && zTerm && zRoot ){
  2903   2903           sqlite3_int64 *pi = (isPrefix ? &iLeavesEndBlock : 0);
  2904   2904           rc = fts3SelectLeaf(p, zTerm, nTerm, zRoot, nRoot, &iStartBlock, pi);
  2905   2905           if( rc!=SQLITE_OK ) goto finished;
  2906   2906           if( isPrefix==0 && isScan==0 ) iLeavesEndBlock = iStartBlock;
  2907   2907         }
  2908   2908    
  2909   2909         rc = sqlite3Fts3SegReaderNew(pCsr->nSegment+1, 

Changes to test/fts3corrupt4.test.

   245    245   | end c15.db
   246    246   }]} {}
   247    247   
   248    248   do_catchsql_test 5.1 {
   249    249     SELECT * FROM t1 WHERE t1 MATCH 'abandon';
   250    250   } {1 {malformed database schema (sqlite_autoindey_t1_segdir_1) - orphan index}}
   251    251   
          252  +
          253  +#-------------------------------------------------------------------------
          254  +reset_db
          255  +do_execsql_test 6.0 {
          256  +  CREATE VIRTUAL TABLE Table0 USING fts3();
          257  +  INSERT INTO Table0_segdir VALUES(1,NULL,1,NULL,NULL,NULL);
          258  +}
          259  +
          260  +do_catchsql_test 6.1 {
          261  +  SELECT * FROM Table0 WHERE Table0 MATCH 'a';
          262  +} {0 {}}
          263  +
          264  +do_catchsql_test 6.2 {
          265  +  INSERT INTO Table0(Table0) VALUES('optimize');
          266  +} {0 {}}
          267  +
   252    268   finish_test