]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
If compiled with memory-debugging, write garbage to memory when it is freed. Fix...
authordanielk1977 <danielk1977@noemail.net>
Tue, 10 Jan 2006 07:14:23 +0000 (07:14 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Tue, 10 Jan 2006 07:14:23 +0000 (07:14 +0000)
FossilOrigin-Name: bd02a6faefa3602d0b93d54bc57809a2222d5903

manifest
manifest.uuid
src/attach.c
src/build.c
src/main.c
src/util.c
test/quick.test

index fd50a7150b17b5ac609496352f9f49bbf2a6cd76..930418fe816298a843860961f5e8250dcd22f16c 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Enable\sshared\scache\son\sthe\sserver\sdemonstration.\s(CVS\s2899)
-D 2006-01-10T02:30:33
+C If\scompiled\swith\smemory-debugging,\swrite\sgarbage\sto\smemory\swhen\sit\sis\sfreed.\sFix\sfor\s#1594.\s(CVS\s2900)
+D 2006-01-10T07:14:23
 F Makefile.in ab3ffd8d469cef4477257169b82810030a6bb967
 F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -32,11 +32,11 @@ F sqlite3.def c413e514217736884254739a105c8c942fdf0c2f
 F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a
 F src/alter.c d0dd079b9ef0d551ff4a4ce09ee270c07b307bbb
 F src/analyze.c ed87abad3f6f60e1bd5308ed6ff6e0fa396db52b
-F src/attach.c b5b63e93ea2cba627033ecc4a671d2d4bc3d06a9
+F src/attach.c 8438a2808f89c01cfd472e676a27d771ac4405aa
 F src/auth.c cdec356a5cd8b217c346f816c5912221537fe87f
 F src/btree.c 5e5dff4a667d93d49925d38de2d451a5bd1eabfd
 F src/btree.h 5663c4f43e8521546ccebc8fc95acb013b8f3184
-F src/build.c db1d1bd861032a8954030be1fcf3b7decb858dbb
+F src/build.c 97997d435acfb9406f776f14931c16559bd534e5
 F src/callback.c 1c2b78a210fda18cdd4d0b604ed41bf0e1f5125c
 F src/complete.c df1681cef40dec33a286006981845f87b194e7a4
 F src/date.c a927bdbb51296ac398d2f667086a7072c099e5ab
@@ -48,7 +48,7 @@ F src/hash.c 8747cf51d12de46512880dfcf1b68b4e24072863
 F src/hash.h 1b0c445e1c89ff2aaad9b4605ba61375af001e84
 F src/insert.c 16610475976dc9b25d231338e283dd4b4362a430
 F src/legacy.c f651ccd3700f99fa05766ac53506bf9a0694761b
-F src/main.c 68563cfa3f67d2784506aafd680eeefd0138cae8
+F src/main.c eb4ba0a5068b7fa086e04338eb78997e9e5c4941
 F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
 F src/os.c 1d1a61cdf150e9f9520a3bc787c8465148ea2e78
 F src/os.h 8710c0068f3386a73a37f8ad242b92c7580464df
@@ -85,7 +85,7 @@ F src/tokenize.c 196486012c871cdcad6cc84a820cc988603f1b9d
 F src/trigger.c c515afa5fe964e9854c54dc66dde179a90d0cfe3
 F src/update.c e09da54cb8e042f89f4177f4ef879b594d8ab946
 F src/utf.c b7bffac4260177ae7f83c01d025fe0f5ed70ce71
-F src/util.c 0153015d99468e994a2c9bc6746262654ed5914a
+F src/util.c 264083f0de25b92c362e88a23402cc76e93613ba
 F src/vacuum.c f5a068096b22fad438bf1f1cf69ccb7f9e8cc7fb
 F src/vdbe.c 490b9b48a8f616b9a15b0151b86212b0fab311b2
 F src/vdbe.h 8729a4ee16ff9aeab2af9667df3cf300ff978e13
@@ -210,7 +210,7 @@ F test/pagesize.test cbc6a312b6f6c0f02619b189985df2a14164b690
 F test/pragma.test 8759b46702f6d8ee4f5dd520216c69dbc9080b60
 F test/printf.test 9e10c74e16bf889f8495ddb3d6f5f891e75ff1b7
 F test/progress.test 16496001da445e6534afb94562c286708316d82f x
-F test/quick.test 51284a17a631110d0d93d0fdcdc0ed25fcc58259
+F test/quick.test 2d2cf1b50e894b19b4029dd9a68ec59599b24f18
 F test/quote.test 5891f2338980916cf7415484b4ce785294044adb
 F test/reindex.test 38b138abe36bf9a08c791ed44d9f76cd6b97b78b
 F test/rollback.test fc6be5a5e4b1347fd96777c65484a24fc75e8f0e
@@ -340,7 +340,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 66f84068f3c7c0963ce88f84fc0ba6775f64cd19
-R c5563d07cb2805e3f2db53bc3bd82ad8
-U drh
-Z 3c5423459a64450bbf5c75dd316847e8
+P 8719f880a395db8be65ea45615d8e55985306f1e
+R b2a531b43730473163449399fcf314d6
+U danielk1977
+Z 8cdee85eddce52cc29622696f9c74204
index 21abf7e59cb90997781073f570f700d8c73ab462..8a620cfe8a07925267bcb0b31564743dae57aaf6 100644 (file)
@@ -1 +1 @@
-8719f880a395db8be65ea45615d8e55985306f1e
\ No newline at end of file
+bd02a6faefa3602d0b93d54bc57809a2222d5903
\ No newline at end of file
index e2d6234d4f3afeed61553b0b40f13162b6e07385..eca7eb7ecf79325b650f57781b5f7002f3116faa 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** This file contains code used to implement the ATTACH and DETACH commands.
 **
-** $Id: attach.c,v 1.43 2006/01/09 23:40:25 drh Exp $
+** $Id: attach.c,v 1.44 2006/01/10 07:14:23 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 
@@ -182,6 +182,7 @@ static void attachFunc(
     if( db->aDb[i].pBt ){
       sqlite3BtreeClose(db->aDb[i].pBt);
       db->aDb[i].pBt = 0;
+      db->aDb[i].pSchema = 0;
     }
     sqlite3ResetInternalSchema(db, 0);
     db->nDb = i;
@@ -243,6 +244,7 @@ static void detachFunc(
 
   sqlite3BtreeClose(pDb->pBt);
   pDb->pBt = 0;
+  pDb->pSchema = 0;
   sqlite3ResetInternalSchema(db, 0);
   return;
 
index 36fbfd6745f040f72ce33033a7f725d46edc9757..3fd4308f12ddd0c50e11fcc46ab118f21cd669a4 100644 (file)
@@ -22,7 +22,7 @@
 **     COMMIT
 **     ROLLBACK
 **
-** $Id: build.c,v 1.373 2006/01/09 23:40:25 drh Exp $
+** $Id: build.c,v 1.374 2006/01/10 07:14:23 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -405,7 +405,7 @@ void sqlite3ResetInternalSchema(sqlite3 *db, int iDb){
   db->flags &= ~SQLITE_InternChanges;
 
   /* If one or more of the auxiliary database files has been closed,
-  ** then remove then from the auxiliary database list.  We take the
+  ** then remove them from the auxiliary database list.  We take the
   ** opportunity to do this here since we have just deleted all of the
   ** schema hash tables and therefore do not have to make any changes
   ** to any of those tables.
index b445908689631784f6d52c7136ac87611dc5f838..9bbb5105bbfd0c06c714092feb92cad96ca11e0a 100644 (file)
@@ -14,7 +14,7 @@
 ** other files are for internal use by SQLite and should not be
 ** accessed by users of the library.
 **
-** $Id: main.c,v 1.320 2006/01/09 16:12:05 danielk1977 Exp $
+** $Id: main.c,v 1.321 2006/01/10 07:14:24 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -139,6 +139,9 @@ int sqlite3_close(sqlite3 *db){
     if( pDb->pBt ){
       sqlite3BtreeClose(pDb->pBt);
       pDb->pBt = 0;
+      if( j!=1 ){
+        pDb->pSchema = 0;
+      }
     }
   }
   sqlite3ResetInternalSchema(db, 0);
@@ -165,7 +168,15 @@ int sqlite3_close(sqlite3 *db){
   }
 
   db->magic = SQLITE_MAGIC_ERROR;
+
+  /* The temp-database schema is allocated differently from the other schema
+  ** objects (using sqliteMalloc() directly, instead of sqlite3BtreeSchema()).
+  ** So it needs to be freed here. Todo: Why not roll the temp schema into
+  ** the same sqliteMalloc() as the one that allocates the database 
+  ** structure?
+  */
   sqliteFree(db->aDb[1].pSchema);
+
   sqliteFree(db);
   sqlite3MallocAllow();
   return SQLITE_OK;
index 4732f23c9c3a95e801784b959ae0c8dd7af5c115..3cfc37276a4a07bcdd2ecf87911154e2892a4a68 100644 (file)
@@ -14,7 +14,7 @@
 ** This file contains functions for allocating memory, comparing
 ** strings, and stuff like that.
 **
-** $Id: util.c,v 1.164 2006/01/09 09:59:49 danielk1977 Exp $
+** $Id: util.c,v 1.165 2006/01/10 07:14:24 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -450,14 +450,23 @@ static void * OSMALLOC(int n){
   return 0;
 }
 
+static int OSSIZEOF(void *p){
+  if( p ){
+    u32 *pOs = (u32 *)getOsPointer(p);
+    return sqlite3OsAllocationSize(pOs) - TESTALLOC_OVERHEAD;
+  }
+  return 0;
+}
+
 /*
 ** This is the test layer's wrapper around sqlite3OsFree(). The argument is a
 ** pointer to the space allocated for the application to use.
 */
-void OSFREE(void *pFree){
+static void OSFREE(void *pFree){
   u32 *p = (u32 *)getOsPointer(pFree);   /* p points to Os level allocation */
   checkGuards(p);
   unlinkAlloc(p);
+  memset(pFree, 0x55, OSSIZEOF(pFree));
   sqlite3OsFree(p);
   sqlite3_nFree++;
 }
@@ -465,7 +474,7 @@ void OSFREE(void *pFree){
 /*
 ** This is the test layer's wrapper around sqlite3OsRealloc().
 */
-void * OSREALLOC(void *pRealloc, int n){
+static void * OSREALLOC(void *pRealloc, int n){
 #ifndef SQLITE_OMIT_MEMORY_MANAGEMENT
   ThreadData *pTsd = sqlite3ThreadData();
   pTsd->nMaxAlloc = MAX(pTsd->nMaxAlloc, pTsd->nAlloc);
@@ -481,18 +490,10 @@ void * OSREALLOC(void *pRealloc, int n){
   return 0;
 }
 
-void OSMALLOC_FAILED(){
+static void OSMALLOC_FAILED(){
   sqlite3ThreadData()->isFail = 0;
 }
 
-int OSSIZEOF(void *p){
-  if( p ){
-    u32 *pOs = (u32 *)getOsPointer(p);
-    return sqlite3OsAllocationSize(pOs) - TESTALLOC_OVERHEAD;
-  }
-  return 0;
-}
-
 #else
 /* Define macros to call the sqlite3OsXXX interface directly if 
 ** the SQLITE_MEMDEBUG macro is not defined.
index cf190713b792058142d3b01667b2e25f4c77c5ba..e23a986f7dae1482bcb03b38b67217b1fe5ed047 100644 (file)
@@ -6,7 +6,7 @@
 #***********************************************************************
 # This file runs all tests.
 #
-# $Id: quick.test,v 1.40 2006/01/09 16:12:05 danielk1977 Exp $
+# $Id: quick.test,v 1.41 2006/01/10 07:14:24 danielk1977 Exp $
 
 proc lshift {lvar} {
   upvar $lvar l
@@ -50,10 +50,9 @@ set EXCLUDE {
   misuse.test
   quick.test
 
-  attachmalloc.test
-  utf16.test
   autovacuum_crash.test
   btree8.test
+  utf16.test
 }
 
 if {[sqlite3 -has-codec]} {