/ Check-in [cb874fd8]
Login

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

Overview
Comment:Fix minor memory leak in the dbstat extension that can occur following an attempt to analyze a corrupt database file.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: cb874fd87384be397008e953242d5773ef5d64e07c3e1ae352a42a25d70597b4
User & Date: drh 2018-10-29 18:33:42
Context
2018-10-29
21:01
Fix a potential assertion fault that can occur while trying to DROP a table from a corrupted database file. check-in: 147a9429 user: drh tags: trunk
18:33
Fix minor memory leak in the dbstat extension that can occur following an attempt to analyze a corrupt database file. check-in: cb874fd8 user: drh tags: trunk
17:08
In the sessions module, avoid collecting rebase data if the user has not requested it. check-in: de72a773 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/dbstat.c.

   250    250       pCsr->iDb = pTab->iDb;
   251    251     }
   252    252   
   253    253     *ppCursor = (sqlite3_vtab_cursor *)pCsr;
   254    254     return SQLITE_OK;
   255    255   }
   256    256   
   257         -static void statClearPage(StatPage *p){
          257  +static void statClearCells(StatPage *p){
   258    258     int i;
   259    259     if( p->aCell ){
   260    260       for(i=0; i<p->nCell; i++){
   261    261         sqlite3_free(p->aCell[i].aOvfl);
   262    262       }
   263    263       sqlite3_free(p->aCell);
   264    264     }
          265  +  p->nCell = 0;
          266  +  p->aCell = 0;
          267  +}
          268  +
          269  +static void statClearPage(StatPage *p){
          270  +  statClearCells(p);
   265    271     sqlite3PagerUnref(p->pPg);
   266    272     sqlite3_free(p->zPath);
   267    273     memset(p, 0, sizeof(StatPage));
   268    274   }
   269    275   
   270    276   static void statResetCsr(StatCursor *pCsr){
   271    277     int i;
................................................................................
   413    419       }
   414    420     }
   415    421   
   416    422     return SQLITE_OK;
   417    423   
   418    424   statPageIsCorrupt:
   419    425     p->flags = 0;
   420         -  p->nCell = 0;
          426  +  statClearCells(p);
   421    427     return SQLITE_OK;
   422    428   }
   423    429   
   424    430   /*
   425    431   ** Populate the pCsr->iOffset and pCsr->szPage member variables. Based on
   426    432   ** the current value of pCsr->iPageno.
   427    433   */