/ Check-in [73128d4e]
Login

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

Overview
Comment:Fix a null-pointer dereference that can occur on an OOM error while running ANALYZE with SQLITE_ENABLE_STAT2.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 73128d4ef5d7703bf7af0553c307b55dc1b783f6
User & Date: drh 2011-01-04 20:06:33
Context
2011-01-05
12:20
Add the sqlite3_vsnprintf() interface. check-in: fc67adea user: drh tags: trunk
2011-01-04
20:06
Fix a null-pointer dereference that can occur on an OOM error while running ANALYZE with SQLITE_ENABLE_STAT2. check-in: 73128d4e user: drh tags: trunk
19:01
Fix the ANALYZE command so that it takes collating sequences into account when gathering index statistics. check-in: a5867cfc user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/analyze.c.

   632    632       }else{
   633    633         rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);
   634    634         sqlite3DbFree(db, zSql);
   635    635       }
   636    636   
   637    637       if( rc==SQLITE_OK ){
   638    638         while( sqlite3_step(pStmt)==SQLITE_ROW ){
   639         -        char *zIndex = (char *)sqlite3_column_text(pStmt, 0);
   640         -        Index *pIdx = sqlite3FindIndex(db, zIndex, sInfo.zDatabase);
          639  +        char *zIndex;   /* Index name */
          640  +        Index *pIdx;    /* Pointer to the index object */
          641  +
          642  +        zIndex = (char *)sqlite3_column_text(pStmt, 0);
          643  +        pIdx = zIndex ? sqlite3FindIndex(db, zIndex, sInfo.zDatabase) : 0;
   641    644           if( pIdx ){
   642    645             int iSample = sqlite3_column_int(pStmt, 1);
   643    646             if( iSample<SQLITE_INDEX_SAMPLES && iSample>=0 ){
   644    647               int eType = sqlite3_column_type(pStmt, 2);
   645    648   
   646    649               if( pIdx->aSample==0 ){
   647    650                 static const int sz = sizeof(IndexSample)*SQLITE_INDEX_SAMPLES;