]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Make sure SQLITE_NOMEM is reported out on a malloc failure in an ATTACH
authordrh <drh@noemail.net>
Wed, 5 Apr 2006 11:57:37 +0000 (11:57 +0000)
committerdrh <drh@noemail.net>
Wed, 5 Apr 2006 11:57:37 +0000 (11:57 +0000)
even if the malloc failure reports within a nested calls to sqlite3_prepare(). (CVS 3164)

FossilOrigin-Name: 3538a4e30fb5131b461bb0cf72cada63e9724e14

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

index 64d8282d86fa461e93648c5f3ab232afdfca0e5e..b8cb7519f8004cf1a9862913f85f3856cb7da7dd 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\sdocumentation\son\snew\ssqlite_authorizer\scallback\stypes.\sTicket\s#1744.\s(CVS\s3163)
-D 2006-04-05T01:08:35
+C Make\ssure\sSQLITE_NOMEM\sis\sreported\sout\son\sa\smalloc\sfailure\sin\san\sATTACH\neven\sif\sthe\smalloc\sfailure\sreports\swithin\sa\snested\scalls\sto\ssqlite3_prepare().\s(CVS\s3164)
+D 2006-04-05T11:57:37
 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 d73a3505de3fb9e373d0a158978116c4212031d0
+F src/attach.c 514f90623c891143846625afcab409d6b4986565
 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 7d875b2b59ae1d79fba71403298a1eb4a1ed7c38
+F test/malloc.test 8580d8fe1f5e78e4ddbe07530e7a5d4ee36aac8f
 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 51b35ace203a33f6f04f1139ca8ab652c5c76f9a
-R 37db2ed2a2f394b32b2c98ec1c3f61dd
+P fdbff3f145296d5dcba8987c25629e27353e2ab0
+R a178117f13217df6aee4e3891a129fac
 U drh
-Z bea39b4c4681bce541ac61af0db836c7
+Z 43dddd673d1c73ea60cfe59bfb56a0fc
index cb159aa2232d05593f9ba9b44d8b21c7cb6b46bc..8f8062d8d9a43f2cdd6c434455ef0a895bbbb9f5 100644 (file)
@@ -1 +1 @@
-fdbff3f145296d5dcba8987c25629e27353e2ab0
\ No newline at end of file
+3538a4e30fb5131b461bb0cf72cada63e9724e14
\ No newline at end of file
index c66b212d16094610e94c7d4079b37c4c619d65d1..318ffa5088c04f1893d033cde7f046e5327f53e0 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** This file contains code used to implement the ATTACH and DETACH commands.
 **
-** $Id: attach.c,v 1.49 2006/01/24 12:09:18 danielk1977 Exp $
+** $Id: attach.c,v 1.50 2006/04/05 11:57:37 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -185,7 +185,12 @@ static void attachFunc(
     }
     sqlite3ResetInternalSchema(db, 0);
     db->nDb = iDb;
-    sqlite3_snprintf(127, zErr, "unable to open database: %s", zFile);
+    if( rc==SQLITE_NOMEM ){
+      sqlite3MallocFailed();
+      sqlite3_snprintf(127, zErr, "out of memory");
+    }else{
+      sqlite3_snprintf(127, zErr, "unable to open database: %s", zFile);
+    }
     goto attach_error;
   }
   
index cbeef245de2b1ad2a03e31a88ebf686175e1b021..2067b5b021aa98e53a8abf6adc6f79a217ae2bf0 100644 (file)
@@ -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.30 2006/01/24 10:58:23 danielk1977 Exp $
+# $Id: malloc.test,v 1.31 2006/04/05 11:57:37 drh Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -513,6 +513,26 @@ do_malloc_test 19 -tclprep {
 }
 unset static_string
 
+# Make sure SQLITE_NOMEM is reported out on an ATTACH failure even
+# when the malloc failure occurs within the nested parse.
+#
+do_malloc_test 20 -tclprep {
+  db close
+  file delete -force test2.db test2.db-journal
+  sqlite3 db test2.db
+  db eval {CREATE TABLE t1(x);}
+  db close
+} -tclbody {
+  if {[catch {sqlite3 db test.db}]} {
+    error "out of memory"
+  }
+} -sqlbody {
+  ATTACH DATABASE 'test2.db' AS t2;
+  SELECT * FROM t1;
+  DETACH DATABASE t2;
+} 
+
+
 # Ensure that no file descriptors were leaked.
 do_test malloc-99.X {
   catch {db close}