1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-09-11 08:30:57 +03:00

Fix an assert() failure that may follow an OOM error.

FossilOrigin-Name: 14a715c5639b2bc69b129485ca32e96366dab4c4
This commit is contained in:
dan
2009-08-19 16:34:31 +00:00
parent 4190326626
commit 0f9a34ea4f
3 changed files with 19 additions and 11 deletions

View File

@@ -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

View File

@@ -1 +1 @@
740a93e89c5f12672d72de7b3c55807deac613d4
14a715c5639b2bc69b129485ca32e96366dab4c4

View 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));