From: drh Date: Mon, 10 Apr 2006 13:37:47 +0000 (+0000) Subject: Follow-up to check-in (3164). Make sure SQLITE_NOMEM is returned after X-Git-Tag: version-3.6.10~2995 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a06ab2ca23b2740c06b07208abc39e3f40719d16;p=thirdparty%2Fsqlite.git Follow-up to check-in (3164). Make sure SQLITE_NOMEM is returned after a memory allocation failure. It is not sufficent to return an "out of memory" error message. The return code needs to be SQLITE_NOMEM. (CVS 3172) FossilOrigin-Name: 9d95750e8556aef20a637a815652d547ed2f887c --- diff --git a/manifest b/manifest index d2e3598c19..3d195cea45 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Variable\sdeclarations\sshould\scome\sbefore\scode.\s\sTicket\s#1763.\s(CVS\s3171) -D 2006-04-08T19:14:53 +C Follow-up\sto\scheck-in\s(3164).\s\sMake\ssure\sSQLITE_NOMEM\sis\sreturned\safter\na\smemory\sallocation\sfailure.\s\sIt\sis\snot\ssufficent\sto\sreturn\san\s"out\sof\smemory"\nerror\smessage.\s\sThe\sreturn\scode\sneeds\sto\sbe\sSQLITE_NOMEM.\s(CVS\s3172) +D 2006-04-10T13:37:47 F Makefile.in 5d8dff443383918b700e495de42ec65bc1c8865b F Makefile.linux-gcc 74ba0eadf88748a9ce3fd03d2a3ede2e6715baec F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 @@ -32,7 +32,7 @@ F sqlite3.def f756049b1bf3e8442baf6862db393ca423225262 F sqlite3.pc.in 985b9bf34192a549d7d370e0f0b6b34a4f61369a F src/alter.c 451b34fc4eb2475ca76a2e86b21e1030a9428091 F src/analyze.c 7d2b7ab9a9c2fd6e55700f69064dfdd3e36d7a8a -F src/attach.c 514f90623c891143846625afcab409d6b4986565 +F src/attach.c 765217a681eb0fb68f95f372604d4fa4594a503f F src/auth.c 9ae84d2d94eb96195e04515715e08e85963e96c2 F src/btree.c ed343b3dbcbc7da9ac481ef2b98c4239fe6d9629 F src/btree.h 40055cfc09defd1146bc5b922399c035f969e56d @@ -191,7 +191,7 @@ F test/lock.test 9b7afcb24f53d24da502abb33daaad2cd6d44107 F test/lock2.test d83ba79d3c4fffdb5b926c7d8ca7a36c34288a55 F test/lock3.test 615111293cf32aa2ed16d01c6611737651c96fb9 F test/main.test e7212ce1023957c7209778cc87fa932bd79ba89a -F test/malloc.test 8580d8fe1f5e78e4ddbe07530e7a5d4ee36aac8f +F test/malloc.test 684510c0e60dfb1660fa441e811ae79e97e8ea82 F test/malloc2.test e6e321db96d6c94cb18bf82ad7215070c41e624e F test/malloc3.test fd4186bee73c2a2638f4e2a05a684c06836f725b F test/malloc4.test 59cd02f71b363302a04c4e77b97c0a1572eaa210 @@ -355,7 +355,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513 -P 1929e37d5e691f9d2bec01deb7bdbbbb6f5ace01 -R 6e7b54ed83595e6937776e7115544edc +P 9682f84401f7e21630246e1c37351425b78b7afa +R 20cddda4405a1c926f2f032a7ab7a815 U drh -Z 44bb100707342686e2ecd726d621c6c1 +Z 63f846bed204f2b1d5e1629dade835cf diff --git a/manifest.uuid b/manifest.uuid index c75a5c8bc3..78c66fb2d6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9682f84401f7e21630246e1c37351425b78b7afa \ No newline at end of file +9d95750e8556aef20a637a815652d547ed2f887c \ No newline at end of file diff --git a/src/attach.c b/src/attach.c index 318ffa5088..7e823930b0 100644 --- a/src/attach.c +++ b/src/attach.c @@ -11,7 +11,7 @@ ************************************************************************* ** This file contains code used to implement the ATTACH and DETACH commands. ** -** $Id: attach.c,v 1.50 2006/04/05 11:57:37 drh Exp $ +** $Id: attach.c,v 1.51 2006/04/10 13:37:47 drh Exp $ */ #include "sqliteInt.h" @@ -186,7 +186,7 @@ static void attachFunc( sqlite3ResetInternalSchema(db, 0); db->nDb = iDb; if( rc==SQLITE_NOMEM ){ - sqlite3MallocFailed(); + if( !sqlite3MallocFailed() ) sqlite3FailedMalloc(); sqlite3_snprintf(127, zErr, "out of memory"); }else{ sqlite3_snprintf(127, zErr, "unable to open database: %s", zFile); diff --git a/test/malloc.test b/test/malloc.test index 2067b5b021..ee091b27c3 100644 --- a/test/malloc.test +++ b/test/malloc.test @@ -14,7 +14,7 @@ # special feature is used 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.31 2006/04/05 11:57:37 drh Exp $ +# $Id: malloc.test,v 1.32 2006/04/10 13:37:47 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -93,6 +93,13 @@ proc do_malloc_test {tn args} { } set v [catch $::mallocbody msg] + # If the test fails (if $v!=0) and the database connection actually + # exists, make sure the failure code is SQLITE_NOMEM. + if {$v && [info command db]=="db" && [info exists ::mallocopts(-sqlbody)] + && [db errorcode]!=7} { + set v 999 + } + set leftover [lindex [sqlite_malloc_stat] 2] if {$leftover>0} { if {$leftover>1} {puts "\nLeftover: $leftover\nReturn=$v Message=$msg"}