Index: src/build.c ================================================================== --- src/build.c +++ src/build.c @@ -20,11 +20,11 @@ ** creating ID lists ** BEGIN TRANSACTION ** COMMIT ** ROLLBACK ** -** $Id: build.c,v 1.498 2008/10/06 16:18:40 danielk1977 Exp $ +** $Id: build.c,v 1.499 2008/10/22 10:45:38 danielk1977 Exp $ */ #include "sqliteInt.h" #include /* @@ -2399,11 +2399,11 @@ ** sqlite3FixSrcList can never fail. */ assert(0); } pTab = sqlite3LocateTable(pParse, 0, pTblName->a[0].zName, pTblName->a[0].zDatabase); - if( !pTab ) goto exit_create_index; + if( !pTab || db->mallocFailed ) goto exit_create_index; assert( db->aDb[iDb].pSchema==pTab->pSchema ); }else{ assert( pName==0 ); pTab = pParse->pNewTable; if( !pTab ) goto exit_create_index; Index: test/attachmalloc.test ================================================================== --- test/attachmalloc.test +++ test/attachmalloc.test @@ -10,11 +10,11 @@ #************************************************************************* # This file implements regression tests for SQLite library. The # focus of this script is testing the ATTACH statement and # specifically out-of-memory conditions within that command. # -# $Id: attachmalloc.test,v 1.9 2008/08/04 20:13:27 drh Exp $ +# $Id: attachmalloc.test,v 1.10 2008/10/22 10:45:38 danielk1977 Exp $ # set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -43,7 +43,21 @@ ATTACH 'test3.db' AS three; CREATE TABLE three.t1(x); ATTACH 'test4.db' AS four; CREATE TABLE four.t1(x); } + +do_malloc_test attachmalloc-2 -tclprep { + file delete -force test2.db + file delete -force test2.db-journal + sqlite3 db2 test2.db + db2 eval { + CREATE TABLE t1(a, b, c); + CREATE INDEX i1 ON t1(a, b); + } + db2 close +} -sqlbody { + CREATE TABLE t1(d, e, f); + ATTACH 'test2.db' AS db1; +} finish_test