/ Check-in [875f8fa3]
Login

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

Overview
Comment:Fix a segfault that can occur if a malloc fails in ATTACH in shared-cache mode.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | compile_opts
Files: files | file ages | folders
SHA1:875f8fa32708b8dbf314fd7056fac2fefdacfa36
User & Date: dan 2010-02-23 10:56:16
Context
2010-02-23
20:08
Refactored compile time option diagnostic support to use strings identifiers instead of bitmask. Closed-Leaf check-in: 76a0294a user: shaneh tags: compile_opts
10:56
Fix a segfault that can occur if a malloc fails in ATTACH in shared-cache mode. check-in: 875f8fa3 user: dan tags: compile_opts
05:17
Removed checking of some compile options from the sqlite3_compileopts() API. check-in: 833da702 user: shaneh tags: compile_opts
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/attach.c.

   143    143       }
   144    144       pPager = sqlite3BtreePager(aNew->pBt);
   145    145       sqlite3PagerLockingMode(pPager, db->dfltLockMode);
   146    146       sqlite3PagerJournalMode(pPager, db->dfltJournalMode);
   147    147       sqlite3BtreeSecureDelete(aNew->pBt,
   148    148                                sqlite3BtreeSecureDelete(db->aDb[0].pBt,-1) );
   149    149     }
   150         -  aNew->zName = sqlite3DbStrDup(db, zName);
   151    150     aNew->safety_level = 3;
          151  +  aNew->zName = sqlite3DbStrDup(db, zName);
          152  +  if( rc==SQLITE_OK && aNew->zName==0 ){
          153  +    rc = SQLITE_NOMEM;
          154  +  }
          155  +
   152    156   
   153    157   #ifdef SQLITE_HAS_CODEC
   154    158     if( rc==SQLITE_OK ){
   155    159       extern int sqlite3CodecAttach(sqlite3*, int, const void*, int);
   156    160       extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*);
   157    161       int nKey;
   158    162       char *zKey;

Changes to test/attachmalloc.test.

    55     55       CREATE INDEX i1 ON t1(a, b);
    56     56     }
    57     57     db2 close
    58     58   } -sqlbody {
    59     59     CREATE TABLE t1(d, e, f);
    60     60     ATTACH 'test2.db' AS db1;
    61     61   }
           62  +
           63  +set enable_shared_cache [sqlite3_enable_shared_cache 1]
           64  +sqlite3 dbaux test2.db
           65  +dbaux eval {SELECT * FROM sqlite_master}
           66  +do_malloc_test attachmalloc-3 -sqlbody {
           67  +  SELECT * FROM sqlite_master;
           68  +  ATTACH 'test2.db' AS two;
           69  +} -cleanup {
           70  +  db eval { DETACH two }
           71  +}
           72  +dbaux close
           73  +sqlite3_enable_shared_cache $enable_shared_cache
           74  +
    62     75   
    63     76   finish_test