/ 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 Unified Diffs Ignore Whitespace Patch

Changes to src/attach.c.

143
144
145
146
147
148
149
150
151





152
153
154
155
156
157
158
    }
    pPager = sqlite3BtreePager(aNew->pBt);
    sqlite3PagerLockingMode(pPager, db->dfltLockMode);
    sqlite3PagerJournalMode(pPager, db->dfltJournalMode);
    sqlite3BtreeSecureDelete(aNew->pBt,
                             sqlite3BtreeSecureDelete(db->aDb[0].pBt,-1) );
  }
  aNew->zName = sqlite3DbStrDup(db, zName);
  aNew->safety_level = 3;






#ifdef SQLITE_HAS_CODEC
  if( rc==SQLITE_OK ){
    extern int sqlite3CodecAttach(sqlite3*, int, const void*, int);
    extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*);
    int nKey;
    char *zKey;







<

>
>
>
>
>







143
144
145
146
147
148
149

150
151
152
153
154
155
156
157
158
159
160
161
162
    }
    pPager = sqlite3BtreePager(aNew->pBt);
    sqlite3PagerLockingMode(pPager, db->dfltLockMode);
    sqlite3PagerJournalMode(pPager, db->dfltJournalMode);
    sqlite3BtreeSecureDelete(aNew->pBt,
                             sqlite3BtreeSecureDelete(db->aDb[0].pBt,-1) );
  }

  aNew->safety_level = 3;
  aNew->zName = sqlite3DbStrDup(db, zName);
  if( rc==SQLITE_OK && aNew->zName==0 ){
    rc = SQLITE_NOMEM;
  }


#ifdef SQLITE_HAS_CODEC
  if( rc==SQLITE_OK ){
    extern int sqlite3CodecAttach(sqlite3*, int, const void*, int);
    extern void sqlite3CodecGetKey(sqlite3*, int, void**, int*);
    int nKey;
    char *zKey;

Changes to test/attachmalloc.test.

55
56
57
58
59
60
61
62













63
    CREATE INDEX i1 ON t1(a, b);
  }
  db2 close
} -sqlbody {
  CREATE TABLE t1(d, e, f);
  ATTACH 'test2.db' AS db1;
}














finish_test








>
>
>
>
>
>
>
>
>
>
>
>
>

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
    CREATE INDEX i1 ON t1(a, b);
  }
  db2 close
} -sqlbody {
  CREATE TABLE t1(d, e, f);
  ATTACH 'test2.db' AS db1;
}

set enable_shared_cache [sqlite3_enable_shared_cache 1]
sqlite3 dbaux test2.db
dbaux eval {SELECT * FROM sqlite_master}
do_malloc_test attachmalloc-3 -sqlbody {
  SELECT * FROM sqlite_master;
  ATTACH 'test2.db' AS two;
} -cleanup {
  db eval { DETACH two }
}
dbaux close
sqlite3_enable_shared_cache $enable_shared_cache


finish_test