]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix a memory leak that can follow a malloc failure in sqlite3_initialize. (CVS 5731)
authordanielk1977 <danielk1977@noemail.net>
Mon, 22 Sep 2008 17:22:19 +0000 (17:22 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Mon, 22 Sep 2008 17:22:19 +0000 (17:22 +0000)
FossilOrigin-Name: 118dc0ba082dd9abba5602dafc86bd56e756db86

manifest
manifest.uuid
src/main.c
test/malloc.test

index 143bee5cfa7a51759ccbf386eaa2c90fc30662a2..e3c21db1d7ee470df545ab7ce43a1aad03ded276 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sinstrumentation\sto\sos_unix.c\sto\stest\sthat\sa\sreturn\svalue\sof\sSQLITE_FULL\sfrom\san\sxSync()\scallback\sis\shandled\scorrectly.\s(CVS\s5730)
-D 2008-09-22T11:46:33
+C Fix\sa\smemory\sleak\sthat\scan\sfollow\sa\smalloc\sfailure\sin\ssqlite3_initialize.\s(CVS\s5731)
+D 2008-09-22T17:22:20
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in d15a7ebfe5e057a72a49805ffb302dbb601c8329
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -118,7 +118,7 @@ F src/insert.c 110cca7845ed5a66c08fdd413b02e706ae34455f
 F src/journal.c cffd2cd214e58c0e99c3ff632b3bee6c7cbb260e
 F src/legacy.c aac57bd984e666059011ea01ec4383892a253be3
 F src/loadext.c 6581a5bbc4d74fcd46dbbcfd695a6a5417f778a2
-F src/main.c 8704f23153fdcf3b748d8e7ca7e4ec7d7cd319be
+F src/main.c 19953a54797208b5350d5dfe3f220734cca28af0
 F src/malloc.c 6c3bcae8ee8885f1705f36306062f82a64d96118
 F src/mem1.c 5a529ff121c55ab067be14de00f86f6dcc4f4fb9
 F src/mem2.c f87e681d0d1ed8436870d089332ed0d27d885b5c
@@ -405,7 +405,7 @@ F test/lock4.test 09d97d52cae18fadfe631552af9880dac6b3ae90
 F test/lock5.test f4eeb0400cf65c37f733cb3c74401136f8c46acd
 F test/lookaside.test 8866ea41301d74993423c99e523322fca09c259e
 F test/main.test 187a9a1b5248ed74a83838c581c15ec6023b555b
-F test/malloc.test cdc0bb8675b972f56bffdb48e7d52a18500ff66f
+F test/malloc.test c5a70f6b9c1def3d49b108ebb487a5d522933cfd
 F test/malloc3.test 094f8195fe8e409bd4da0f1d769f7745faec62c8
 F test/malloc4.test 957337613002b7058a85116493a262f679f3a261
 F test/malloc5.test c8d0f7673337e8a29afa558735ae937a0d629751
@@ -637,7 +637,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 1dbced29de5f59ba2ebf877edcadf171540374d1
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 1634fd223d65a6ad461f79ca922b5ef967ae763d
-R 698b4c94e662dc747c35b026461fede7
+P 7bd2da93c6cce52edbbe53fe26a82ad159dd6b6b
+R 1d180ffa7242175bc8c7caff350d401f
 U danielk1977
-Z 12625cc77a189a02eb1bc64110fc5009
+Z 502f4e6fe483d957c00be49b346a4200
index 1cffd51a2597eb94e3d7d903b86bc6f315ec23bd..2f108f6dc1b33ef82143669e065510dd0e29a64a 100644 (file)
@@ -1 +1 @@
-7bd2da93c6cce52edbbe53fe26a82ad159dd6b6b
\ No newline at end of file
+118dc0ba082dd9abba5602dafc86bd56e756db86
\ No newline at end of file
index 749d14c9a32b2e6a344f97ea6e1bbbd7f418e442..b107db68958ffdce602e7e75fa1f270c9689b4ae 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.500 2008/09/08 08:08:09 danielk1977 Exp $
+** $Id: main.c,v 1.501 2008/09/22 17:22:20 danielk1977 Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -135,6 +135,8 @@ int sqlite3_initialize(void){
         rc = SQLITE_NOMEM;
       }
     }
+  }
+  if( rc==SQLITE_OK ){
     sqlite3GlobalConfig.nRefInitMutex++;
   }
   sqlite3_mutex_leave(pMaster);
index 42ac8524f95298af0b5b876563695e5e6252298d..45349e8dc51291885faf67f67810a8cbd9c08dc7 100644 (file)
@@ -16,7 +16,7 @@
 # to see what happens in the library if a malloc were to really fail
 # due to an out-of-memory situation.
 #
-# $Id: malloc.test,v 1.65 2008/09/05 05:02:47 danielk1977 Exp $
+# $Id: malloc.test,v 1.66 2008/09/22 17:22:20 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -39,6 +39,7 @@ sqlite3_memdebug_dump $testdir
 puts "Memory dump to file memdump.txt..."
 sqlite3_memdebug_dump memdump.txt
 
+
 ifcapable bloblit&&subquery {
   do_malloc_test 1 -tclprep {
     db close
@@ -636,6 +637,19 @@ do_malloc_test 26 -sqlprep {
   db eval { INSERT INTO t1 VALUES(1, randomblob(210)) }
 }
 
+# Test that no memory is leaked following a malloc() failure in
+# sqlite3_initialize().
+#
+do_malloc_test 27 -tclprep {
+  db close
+  sqlite3_shutdown
+} -tclbody {
+  set rc [sqlite3_initialize]
+  if {$rc == "SQLITE_NOMEM"} {
+    error "out of memory"
+  }
+}
+
 # Ensure that no file descriptors were leaked.
 do_test malloc-99.X {
   catch {db close}