/ Check-in [5ab2b3e3]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Fix an assert() in btree.c that might have fired on a corrupt database file.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5ab2b3e300b70bc04cdead69275f8f734ea2d885
User & Date: drh 2009-12-03 21:26:53
Context
2009-12-04
01:44
Clear a conflicting TCL variable in the fts3rnd.test test script. check-in: f9047b2e user: drh tags: trunk
2009-12-03
21:26
Fix an assert() in btree.c that might have fired on a corrupt database file. check-in: 5ab2b3e3 user: drh tags: trunk
19:40
Remove a NEVER() from btree.c that could occur in a very obscure tested evaluation with an I/O error on fstat(). check-in: d5861d9f user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

  5291   5291     int nSkip = (iChild ? 4 : 0);
  5292   5292   
  5293   5293     if( *pRC ) return;
  5294   5294   
  5295   5295     assert( i>=0 && i<=pPage->nCell+pPage->nOverflow );
  5296   5296     assert( pPage->nCell<=MX_CELL(pPage->pBt) && MX_CELL(pPage->pBt)<=5460 );
  5297   5297     assert( pPage->nOverflow<=ArraySize(pPage->aOvfl) );
  5298         -  assert( sz==cellSizePtr(pPage, pCell) );
  5299   5298     assert( sqlite3_mutex_held(pPage->pBt->mutex) );
         5299  +  /* The cell should normally be sized correctly.  However, when moving a
         5300  +  ** malformed cell from a leaf page to an interior page, if the cell size
         5301  +  ** wanted to be less than 4 but got rounded up to 4 on the leaf, then size
         5302  +  ** might be less than 8 (leaf-size + pointer) on the interior node.  Hence
         5303  +  ** the term after the || in the following assert(). */
         5304  +  assert( sz==cellSizePtr(pPage, pCell) || (sz==8 && iChild>0) );
  5300   5305     if( pPage->nOverflow || sz+2>pPage->nFree ){
  5301   5306       if( pTemp ){
  5302   5307         memcpy(pTemp+nSkip, pCell+nSkip, sz-nSkip);
  5303   5308         pCell = pTemp;
  5304   5309       }
  5305   5310       if( iChild ){
  5306   5311         put4byte(pCell, iChild);