/ Check-in [d6343d03]
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 | branch-3.6.1
Files: files | file ages | folders
SHA1:d6343d035df36217e44549cfbcd9c1138658266c
User & Date: dan 2010-02-23 10:50:27
Context
2010-02-25
14:44
Add some technically unnecessary variable initializations to silence compiler warnings. check-in: a2550597 user: dan tags: branch-3.6.1
2010-02-23
10:50
Fix a segfault that can occur if a malloc fails in ATTACH in shared-cache mode. check-in: d6343d03 user: dan tags: branch-3.6.1
2010-01-05
18:11
Apply fix [9b8acf8319] to the 3.6.1 branch. check-in: 62b4891b user: dan tags: branch-3.6.1
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/attach.c.

140
141
142
143
144
145
146
147
148




149
150
151
152
153
154
155
        "attached databases must use the same text encoding as main database");
      goto attach_error;
    }
    pPager = sqlite3BtreePager(aNew->pBt);
    sqlite3PagerLockingMode(pPager, db->dfltLockMode);
    sqlite3PagerJournalMode(pPager, db->dfltJournalMode);
  }
  aNew->zName = sqlite3DbStrDup(db, zName);
  aNew->safety_level = 3;





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







<

>
>
>
>







140
141
142
143
144
145
146

147
148
149
150
151
152
153
154
155
156
157
158
        "attached databases must use the same text encoding as main database");
      goto attach_error;
    }
    pPager = sqlite3BtreePager(aNew->pBt);
    sqlite3PagerLockingMode(pPager, db->dfltLockMode);
    sqlite3PagerJournalMode(pPager, db->dfltJournalMode);
  }

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

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

Changes to test/attachmalloc.test.

41
42
43
44
45
46
47
48












49
  ATTACH 'test2.db' AS two;
  CREATE TABLE two.t1(x);
  ATTACH 'test3.db' AS three;
  CREATE TABLE three.t1(x);
  ATTACH 'test4.db' AS four;
  CREATE TABLE four.t1(x);
}













finish_test








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

41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  ATTACH 'test2.db' AS two;
  CREATE TABLE two.t1(x);
  ATTACH 'test3.db' AS three;
  CREATE TABLE three.t1(x);
  ATTACH 'test4.db' AS four;
  CREATE TABLE four.t1(x);
}

set enable_shared_cache [sqlite3_enable_shared_cache 1]
sqlite3 dbaux test2.db
dbaux eval {SELECT * FROM sqlite_master}
do_malloc_test attachmalloc-2 -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