diff options
author | drh <drh@noemail.net> | 2004-06-22 13:22:40 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2004-06-22 13:22:40 +0000 |
commit | 645f63ed02f246e9c8d853c39db1cfd46ae0528b (patch) | |
tree | c928059ee55cedbfd19fdb4f3b878946bf68e68b /src | |
parent | d1e3bee1a057a940a92e0af24380a6ae72318e56 (diff) | |
download | sqlite-645f63ed02f246e9c8d853c39db1cfd46ae0528b.tar.gz sqlite-645f63ed02f246e9c8d853c39db1cfd46ae0528b.zip |
Fix some segfaults that could have occurred after a malloc() failure. (CVS 1661)
FossilOrigin-Name: 80151e728101c3cd5a8cf36cca2bfa661b21c746
Diffstat (limited to 'src')
-rw-r--r-- | src/build.c | 3 | ||||
-rw-r--r-- | src/trigger.c | 2 | ||||
-rw-r--r-- | src/vdbe.c | 18 | ||||
-rw-r--r-- | src/vdbeaux.c | 2 |
4 files changed, 6 insertions, 19 deletions
diff --git a/src/build.c b/src/build.c index 4a6ece04e..550504150 100644 --- a/src/build.c +++ b/src/build.c @@ -23,7 +23,7 @@ ** ROLLBACK ** PRAGMA ** -** $Id: build.c,v 1.231 2004/06/22 12:18:32 danielk1977 Exp $ +** $Id: build.c,v 1.232 2004/06/22 13:22:40 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -121,6 +121,7 @@ Table *sqlite3FindTable(sqlite *db, const char *zName, const char *zDatabase){ Table *p = 0; int i; int rc = sqlite3ReadSchema(db, 0); + assert( zName!=0 ); for(i=0; rc==SQLITE_OK && i<db->nDb; i++){ int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */ if( zDatabase!=0 && sqlite3StrICmp(zDatabase, db->aDb[j].zName) ) continue; diff --git a/src/trigger.c b/src/trigger.c index a10474f0b..b0dcc4c27 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -79,7 +79,7 @@ void sqlite3BeginTrigger( ** If sqlite3SrcListLookup() returns 0, indicating the table does not ** exist, the error is caught by the block below. */ - if( !pTableName ) goto trigger_cleanup; + if( !pTableName || sqlite3_malloc_failed ) goto trigger_cleanup; pTab = sqlite3SrcListLookup(pParse, pTableName); if( pName2->n==0 && pTab && pTab->iDb==1 ){ iDb = 1; diff --git a/src/vdbe.c b/src/vdbe.c index 439df02a0..c8276debc 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -43,7 +43,7 @@ ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** -** $Id: vdbe.c,v 1.385 2004/06/21 11:30:56 danielk1977 Exp $ +** $Id: vdbe.c,v 1.386 2004/06/22 13:22:41 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -186,20 +186,6 @@ static int AggInsert(Agg *p, char *zKey, int nKey){ } /* -** Get the AggElem currently in focus -*/ -#if 0 -#define AggInFocus(P) ((P).pCurrent ? (P).pCurrent : _AggInFocus(&(P))) -static AggElem *_AggInFocus(Agg *p){ - HashElem *pElem = sqliteHashFirst(&p->hash); - if( pElem==0 ){ - AggInsert(p,"",1); - pElem = sqliteHashFirst(&p->hash); - } - return pElem ? sqliteHashData(pElem) : 0; -} -#endif -/* ** Store a pointer to the AggElem currently in focus in *ppElem. Return ** SQLITE_OK if successful, otherwise an error-code. */ @@ -4223,7 +4209,7 @@ case OP_AggReset: { if( pOp->p1 ){ rc = sqlite3VdbeAggReset(0, &p->agg, (KeyInfo *)pOp->p3); p->agg.nMem = pOp->p2; /* Agg.nMem is used by AggInsert() */ - AggInsert(&p->agg, 0, 0); + rc = AggInsert(&p->agg, 0, 0); }else{ rc = sqlite3VdbeAggReset(db, &p->agg, (KeyInfo *)pOp->p3); p->agg.nMem = pOp->p2; diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 38c8974b5..249d32c8b 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -679,7 +679,7 @@ void freeAggElem(AggElem *pElem, Agg *pAgg){ int i; for(i=0; i<pAgg->nMem; i++){ Mem *pMem = &pElem->aMem[i]; - if( pAgg->apFunc[i] && (pMem->flags & MEM_AggCtx)!=0 ){ + if( pAgg->apFunc && pAgg->apFunc[i] && (pMem->flags & MEM_AggCtx)!=0 ){ sqlite3_context ctx; ctx.pFunc = pAgg->apFunc[i]; ctx.s.flags = MEM_Null; |