]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix an assert() failure that may follow an OOM error.
authordan <dan@noemail.net>
Wed, 19 Aug 2009 16:34:31 +0000 (16:34 +0000)
committerdan <dan@noemail.net>
Wed, 19 Aug 2009 16:34:31 +0000 (16:34 +0000)
FossilOrigin-Name: 14a715c5639b2bc69b129485ca32e96366dab4c4

manifest
manifest.uuid
src/analyze.c

index ab6c77904352ea0acc99f8962bd87ca07e4cd42c..d114685acf38210c741b091106b42610372c4aa2 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Merge\s29cafcfdcc\sand\sa6f39181a7.
-D 2009-08-19T16:21:25
+C Fix\san\sassert()\sfailure\sthat\smay\sfollow\san\sOOM\serror.
+D 2009-08-19T16:34:31
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 0f7761c5d1c62ae7a841e3393ffaff1fa0f5c00a
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -100,7 +100,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
 F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc
 F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad
 F src/alter.c 8b42cace4f8e312de596807ba2685179da64fec4
-F src/analyze.c 985949131d55e3d9551cf00bff48409660a36a46
+F src/analyze.c b62fc66fce1f7ac0336f10189ce8a7b809c65b2d
 F src/attach.c 13995348fc5a26cdd136a50806faf292aabc173f
 F src/auth.c 802a9439dfa0b8c208b10055cba400e82ef18025
 F src/backup.c 6f1c2d9862c8a3feb7739dfcca02c1f5352e37f3
@@ -747,7 +747,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746
-P a6f39181a7b3083ae46cffd7aee7db895b4df8a4 29cafcfdccf4c0a27746b9a82fa4191605a4505a
-R b5880e12c2965a2d2acde35170c6f032
+P 740a93e89c5f12672d72de7b3c55807deac613d4
+R 0c503f3d121dc88e27c6f16947df7b7a
 U dan
-Z 4c51918a8057669ddd4c52a9aadb5b1c
+Z 349f817f99fd27db57dd3a92eb75a026
index 8a30bf9ec1132f71db4d6c997320a43466984fbf..0ccacc36488081a3eb3596df61fa0ea6f4458ad1 100644 (file)
@@ -1 +1 @@
-740a93e89c5f12672d72de7b3c55807deac613d4
\ No newline at end of file
+14a715c5639b2bc69b129485ca32e96366dab4c4
\ No newline at end of file
index 31acbc381547242051a76de3a2c914f65f6ac57f..67495e380768fae234f716fe42c31ba5a1ad1381 100644 (file)
@@ -108,6 +108,7 @@ static void analyzeOneTable(
   int iStatCur,    /* Index of VdbeCursor that writes the sqlite_stat1 table */
   int iMem         /* Available memory locations begin here */
 ){
+  sqlite3 *db = pParse->db;    /* Database handle */
   Index *pIdx;                 /* An index to being analyzed */
   int iIdxCur;                 /* Cursor open on index being analyzed */
   Vdbe *v;                     /* The virtual machine being built up */
@@ -135,12 +136,12 @@ static void analyzeOneTable(
     /* Do no analysis for tables that have no indices */
     return;
   }
-  assert( sqlite3BtreeHoldsAllMutexes(pParse->db) );
-  iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
+  assert( sqlite3BtreeHoldsAllMutexes(db) );
+  iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
   assert( iDb>=0 );
 #ifndef SQLITE_OMIT_AUTHORIZATION
   if( sqlite3AuthCheck(pParse, SQLITE_ANALYZE, pTab->zName, 0,
-      pParse->db->aDb[iDb].zName ) ){
+      db->aDb[iDb].zName ) ){
     return;
   }
 #endif
@@ -158,7 +159,7 @@ static void analyzeOneTable(
     }
 
     /* Open a cursor to the index to be analyzed. */
-    assert( iDb==sqlite3SchemaToIndex(pParse->db, pIdx->pSchema) );
+    assert( iDb==sqlite3SchemaToIndex(db, pIdx->pSchema) );
     sqlite3VdbeAddOp4(v, OP_OpenRead, iIdxCur, pIdx->tnum, iDb,
         (char *)pKey, P4_KEYINFO_HANDOFF);
     VdbeComment((v, "%s", pIdx->zName));
@@ -260,6 +261,13 @@ static void analyzeOneTable(
       /**** TODO:  add collating sequence *****/
       sqlite3VdbeChangeP5(v, SQLITE_JUMPIFNULL);
     }
+    if( db->mallocFailed ){
+      /* If a malloc failure has occurred, then the result of the expression 
+      ** passed as the second argument to the call to sqlite3VdbeJumpHere() 
+      ** below may be negative. Which causes an assert() to fail (or an
+      ** out-of-bounds write if SQLITE_DEBUG is not defined).  */
+      return;
+    }
     sqlite3VdbeAddOp2(v, OP_Goto, 0, endOfLoop);
     for(i=0; i<nCol; i++){
       sqlite3VdbeJumpHere(v, sqlite3VdbeCurrentAddr(v)-(nCol*2));