/ Check-in [c72abbe2]
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 obscure memory leak in sqlite3Stat4ProbeFree()
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c72abbe2c1735f3d563c6672616b2918b6209922
User & Date: drh 2015-04-20 13:59:18
Context
2015-04-20
15:13
Fix a memory leak caused by duplicate entries in the sqlite_stat1 table. check-in: 2f58c8c9 user: dan tags: trunk
13:59
Fix an obscure memory leak in sqlite3Stat4ProbeFree() check-in: c72abbe2 user: drh tags: trunk
12:50
Enhance fuzzershell to support multiple blocks of SQL, each run in its own private in-memory database. check-in: ab0a96ca user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbemem.c.

  1643   1643   void sqlite3Stat4ProbeFree(UnpackedRecord *pRec){
  1644   1644     if( pRec ){
  1645   1645       int i;
  1646   1646       int nCol = pRec->pKeyInfo->nField+pRec->pKeyInfo->nXField;
  1647   1647       Mem *aMem = pRec->aMem;
  1648   1648       sqlite3 *db = aMem[0].db;
  1649   1649       for(i=0; i<nCol; i++){
  1650         -      if( aMem[i].szMalloc ) sqlite3DbFree(db, aMem[i].zMalloc);
         1650  +      sqlite3VdbeMemRelease(&aMem[i]);
  1651   1651       }
  1652   1652       sqlite3KeyInfoUnref(pRec->pKeyInfo);
  1653   1653       sqlite3DbFree(db, pRec);
  1654   1654     }
  1655   1655   }
  1656   1656   #endif /* ifdef SQLITE_ENABLE_STAT4 */
  1657   1657   

Changes to test/analyze3.test.

   657    657   do_eqp_test analyze3-6-3 {
   658    658     SELECT * FROM t1 WHERE a = 5 AND c = 13;
   659    659   } {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (c=?)}}
   660    660   
   661    661   do_eqp_test analyze3-6-2 {
   662    662     SELECT * FROM t1 WHERE a = 5 AND b > 'w' AND c = 13;
   663    663   } {0 0 0 {SEARCH TABLE t1 USING INDEX i2 (c=?)}}
          664  +
          665  +#-----------------------------------------------------------------------------
          666  +# 2015-04-20.
          667  +# Memory leak in sqlite3Stat4ProbeFree().  (Discovered while fuzzing.)
          668  +#
          669  +do_execsql_test analyze-7.1 {
          670  +  DROP TABLE IF EXISTS t1;
          671  +  CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
          672  +  INSERT INTO t1 VALUES(1,1,'0000');
          673  +  CREATE INDEX t0b ON t1(b);
          674  +  ANALYZE;
          675  +  SELECT c FROM t1 WHERE b=3 AND a BETWEEN 30 AND hex(1);
          676  +} {}
   664    677   
   665    678   finish_test