diff options
author | drh <drh@noemail.net> | 2007-08-22 20:18:21 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2007-08-22 20:18:21 +0000 |
commit | f3a65f7e443865f00b6799ba9637604b0ae55dc5 (patch) | |
tree | 5fc48b237b66cb49164f136fd222f6a49a21c304 /src | |
parent | dd97a49c1a90e31dae5d47ee91e2618eb4b57eb8 (diff) | |
download | sqlite-f3a65f7e443865f00b6799ba9637604b0ae55dc5.tar.gz sqlite-f3a65f7e443865f00b6799ba9637604b0ae55dc5.zip |
The malloc.test script now passes all tests with no errors. (CVS 4271)
FossilOrigin-Name: db818430e9ea4ef4a4af575784009d5acae785a3
Diffstat (limited to 'src')
-rw-r--r-- | src/build.c | 5 | ||||
-rw-r--r-- | src/callback.c | 8 | ||||
-rw-r--r-- | src/expr.c | 6 | ||||
-rw-r--r-- | src/legacy.c | 4 | ||||
-rw-r--r-- | src/main.c | 6 | ||||
-rw-r--r-- | src/malloc.c | 4 | ||||
-rw-r--r-- | src/mem1.c | 11 | ||||
-rw-r--r-- | src/mem2.c | 20 | ||||
-rw-r--r-- | src/os_unix.c | 7 | ||||
-rw-r--r-- | src/printf.c | 6 | ||||
-rw-r--r-- | src/sqlite.h.in | 6 | ||||
-rw-r--r-- | src/sqlite3ext.h | 6 | ||||
-rw-r--r-- | src/tclsqlite.c | 33 | ||||
-rw-r--r-- | src/test1.c | 22 | ||||
-rw-r--r-- | src/test_config.c | 8 | ||||
-rw-r--r-- | src/test_md5.c | 6 | ||||
-rw-r--r-- | src/tokenize.c | 3 | ||||
-rw-r--r-- | src/trigger.c | 8 | ||||
-rw-r--r-- | src/vdbemem.c | 2 |
19 files changed, 98 insertions, 73 deletions
diff --git a/src/build.c b/src/build.c index 0e7523c19..a68137ded 100644 --- a/src/build.c +++ b/src/build.c @@ -22,7 +22,7 @@ ** COMMIT ** ROLLBACK ** -** $Id: build.c,v 1.437 2007/08/21 19:33:56 drh Exp $ +** $Id: build.c,v 1.438 2007/08/22 20:18:22 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -90,6 +90,9 @@ void sqlite3TableLock( p->iTab = iTab; p->isWriteLock = isWriteLock; p->zName = zName; + }else{ + pParse->nTableLock = 0; + pParse->db->mallocFailed = 1; } } diff --git a/src/callback.c b/src/callback.c index 46de7661a..181f26f1b 100644 --- a/src/callback.c +++ b/src/callback.c @@ -13,7 +13,7 @@ ** This file contains functions used to access the internal hash tables ** of user defined functions and collation sequences. ** -** $Id: callback.c,v 1.21 2007/08/21 19:33:56 drh Exp $ +** $Id: callback.c,v 1.22 2007/08/22 20:18:22 drh Exp $ */ #include "sqliteInt.h" @@ -179,8 +179,9 @@ static CollSeq *findCollSeqEntry( ** return the pColl pointer to be deleted (because it wasn't added ** to the hash table). */ - assert( !pDel || (db->mallocFailed && pDel==pColl) ); - if( pDel ){ + assert( pDel==0 || pDel==pColl ); + if( pDel!=0 ){ + db->mallocFailed = 1; sqlite3_free(pDel); pColl = 0; } @@ -310,6 +311,7 @@ FuncDef *sqlite3FindFunction( memcpy(pBest->zName, zName, nName); pBest->zName[nName] = 0; if( pBest==sqlite3HashInsert(&db->aFunc,pBest->zName,nName,(void*)pBest) ){ + db->mallocFailed = 1; sqlite3_free(pBest); return 0; } diff --git a/src/expr.c b/src/expr.c index e541e7d7d..1d1fb0e18 100644 --- a/src/expr.c +++ b/src/expr.c @@ -12,7 +12,7 @@ ** This file contains routines used for analyzing expressions and ** for generating VDBE code that evaluates expressions in SQLite. ** -** $Id: expr.c,v 1.307 2007/08/16 12:24:02 drh Exp $ +** $Id: expr.c,v 1.308 2007/08/22 20:18:22 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -275,8 +275,6 @@ Expr *sqlite3PExpr( ){ Expr *pNew = sqlite3Expr(op, pLeft, pRight, pToken); if( pNew==0 ){ - sqlite3ExprDelete(pLeft); - sqlite3ExprDelete(pRight); pParse->db->mallocFailed = 1; } return pNew; @@ -339,7 +337,7 @@ Expr *sqlite3ExprAnd(sqlite3 *db, Expr *pLeft, Expr *pRight){ void sqlite3ExprSpan(Expr *pExpr, Token *pLeft, Token *pRight){ assert( pRight!=0 ); assert( pLeft!=0 ); - if( pRight->z && pLeft->z ){ + if( pExpr && pRight->z && pLeft->z ){ assert( pLeft->dyn==0 || pLeft->z[pLeft->n]==0 ); if( pLeft->dyn==0 && pRight->dyn==0 ){ pExpr->span.z = pLeft->z; diff --git a/src/legacy.c b/src/legacy.c index acb169470..72637b268 100644 --- a/src/legacy.c +++ b/src/legacy.c @@ -14,7 +14,7 @@ ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** -** $Id: legacy.c,v 1.20 2007/08/21 10:44:16 drh Exp $ +** $Id: legacy.c,v 1.21 2007/08/22 20:18:22 drh Exp $ */ #include "sqliteInt.h" @@ -115,7 +115,7 @@ exec_out: if( pStmt ) sqlite3_finalize(pStmt); if( azCols ) sqlite3_free(azCols); - rc = sqlite3ApiExit(0, rc); + rc = sqlite3ApiExit(db, rc); if( rc!=SQLITE_OK && rc==sqlite3_errcode(db) && pzErrMsg ){ int nErrMsg = 1 + strlen(sqlite3_errmsg(db)); *pzErrMsg = sqlite3_malloc(nErrMsg); diff --git a/src/main.c b/src/main.c index 6baea4bac..b08aca170 100644 --- a/src/main.c +++ b/src/main.c @@ -14,7 +14,7 @@ ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** -** $Id: main.c,v 1.395 2007/08/22 02:56:44 drh Exp $ +** $Id: main.c,v 1.396 2007/08/22 20:18:22 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -1076,7 +1076,9 @@ static int openDatabase( #endif opendb_out: - sqlite3_mutex_leave(db->mutex); + if( db ){ + sqlite3_mutex_leave(db->mutex); + } if( SQLITE_NOMEM==(rc = sqlite3_errcode(db)) ){ sqlite3_close(db); db = 0; diff --git a/src/malloc.c b/src/malloc.c index c8a5025ea..62fa2d2fa 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -12,7 +12,7 @@ ** Memory allocation functions used throughout sqlite. ** ** -** $Id: malloc.c,v 1.9 2007/08/22 00:39:20 drh Exp $ +** $Id: malloc.c,v 1.10 2007/08/22 20:18:22 drh Exp $ */ #include "sqliteInt.h" #include <stdarg.h> @@ -97,7 +97,7 @@ void *sqlite3DbMallocZero(sqlite3 *db, unsigned n){ */ void *sqlite3DbMallocRaw(sqlite3 *db, unsigned n){ void *p = sqlite3_malloc(n); - if( !p ){ + if( !p && db ){ db->mallocFailed = 1; } return p; diff --git a/src/mem1.c b/src/mem1.c index 52f61547f..5a533005d 100644 --- a/src/mem1.c +++ b/src/mem1.c @@ -12,7 +12,7 @@ ** This file contains the C functions that implement a memory ** allocation subsystem for use by SQLite. ** -** $Id: mem1.c,v 1.6 2007/08/17 15:53:36 danielk1977 Exp $ +** $Id: mem1.c,v 1.7 2007/08/22 20:18:22 drh Exp $ */ /* @@ -148,8 +148,11 @@ static void sqlite3MemsysAlarm(unsigned nByte){ /* ** Allocate nBytes of memory */ -void *sqlite3_malloc(unsigned int nBytes){ +void *sqlite3_malloc(int nBytes){ sqlite3_uint64 *p; + if( nBytes<=0 ){ + return 0; + } if( mem.mutex==0 ){ mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM); } @@ -196,13 +199,13 @@ void sqlite3_free(void *pPrior){ /* ** Change the size of an existing memory allocation */ -void *sqlite3_realloc(void *pPrior, unsigned int nBytes){ +void *sqlite3_realloc(void *pPrior, int nBytes){ unsigned nOld; sqlite3_uint64 *p; if( pPrior==0 ){ return sqlite3_malloc(nBytes); } - if( nBytes==0 ){ + if( nBytes<=0 ){ sqlite3_free(pPrior); return 0; } diff --git a/src/mem2.c b/src/mem2.c index a88802dce..57a610225 100644 --- a/src/mem2.c +++ b/src/mem2.c @@ -12,7 +12,7 @@ ** This file contains the C functions that implement a memory ** allocation subsystem for use by SQLite. ** -** $Id: mem2.c,v 1.5 2007/08/20 22:48:43 drh Exp $ +** $Id: mem2.c,v 1.6 2007/08/22 20:18:22 drh Exp $ */ /* @@ -249,13 +249,16 @@ static void sqlite3MemsysFailed(void){ /* ** Allocate nByte bytes of memory. */ -void *sqlite3_malloc(unsigned int nByte){ +void *sqlite3_malloc(int nByte){ struct MemBlockHdr *pHdr; void **pBt; unsigned int *pInt; void *p; unsigned int totalSize; + if( nByte<=0 ){ + return 0; + } if( mem.mutex==0 ){ mem.mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM); } @@ -364,13 +367,13 @@ void sqlite3_free(void *pPrior){ ** much more likely to break and we are much more liking to find ** the error. */ -void *sqlite3_realloc(void *pPrior, unsigned int nByte){ +void *sqlite3_realloc(void *pPrior, int nByte){ struct MemBlockHdr *pOldHdr; void *pNew; if( pPrior==0 ){ return sqlite3_malloc(nByte); } - if( nByte==0 ){ + if( nByte<=0 ){ sqlite3_free(pPrior); return 0; } @@ -430,9 +433,10 @@ void sqlite3_memdebug_dump(const char *zFilename){ ** This routine is used to simulate malloc failures. ** ** After calling this routine, there will be iFail successful -** memory allocations and then a failure. If iRepeat is true, +** memory allocations and then a failure. If iRepeat is 1 ** all subsequent memory allocations will fail. If iRepeat is -** false, only a single allocation will fail. +** 0, only a single allocation will fail. If iRepeat is negative +** then the previous setting for iRepeat is unchanged. ** ** Each call to this routine overrides the previous. To disable ** the simulated allocation failure mechanism, set iFail to -1. @@ -443,7 +447,9 @@ void sqlite3_memdebug_dump(const char *zFilename){ int sqlite3_memdebug_fail(int iFail, int iRepeat){ int n = mem.iFailCnt; mem.iFail = iFail+1; - mem.iReset = iRepeat; + if( iRepeat>=0 ){ + mem.iReset = iRepeat; + } mem.iFailCnt = 0; return n; } diff --git a/src/os_unix.c b/src/os_unix.c index 066ae6e58..75cf36e8d 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -2317,14 +2317,10 @@ static int fillInUnixFile( ** the file descriptor *pFd using close(). */ static int openDirectory(const char *zFilename, int *pFd){ - char *zDirname; int ii; int fd; + char zDirname[MAX_PATHNAME+1]; - zDirname = (char *)sqlite3_malloc(MAX_PATHNAME); - if( !zDirname ){ - return SQLITE_NOMEM; - } strncpy(zDirname, zFilename, MAX_PATHNAME); zDirname[MAX_PATHNAME-1] = '\0'; for(ii=strlen(zDirname); ii>=0 && zDirname[ii]!='/'; ii--); @@ -2338,7 +2334,6 @@ static int openDirectory(const char *zFilename, int *pFd){ OSTRACE3("OPENDIR %-3d %s\n", fd, zDirname); } } - sqlite3_free(zDirname); *pFd = fd; return (fd>0?SQLITE_OK:SQLITE_CANTOPEN); } diff --git a/src/printf.c b/src/printf.c index 55fe3566a..ece53b7fd 100644 --- a/src/printf.c +++ b/src/printf.c @@ -717,7 +717,7 @@ struct sgMprintf { int nChar; /* Length of the string so far */ int nTotal; /* Output size if unconstrained */ int nAlloc; /* Amount of space allocated in zText */ - void *(*xRealloc)(void*, unsigned int); /* Function used to realloc memory */ + void *(*xRealloc)(void*,int); /* Function used to realloc memory */ }; /* @@ -769,7 +769,7 @@ static void mout(void *arg, const char *zNewText, int nNewChar){ ** the consumer. */ static char *base_vprintf( - void *(*xRealloc)(void*, unsigned int), /* realloc() function. May be NULL */ + void *(*xRealloc)(void*, int), /* realloc() function. May be NULL */ int useInternal, /* Use internal %-conversions if true */ char *zInitBuf, /* Initially write here, before mallocing */ int nInitBuf, /* Size of zInitBuf[] */ @@ -801,7 +801,7 @@ static char *base_vprintf( /* ** Realloc that is a real function, not a macro. */ -static void *printf_realloc(void *old, unsigned int size){ +static void *printf_realloc(void *old, int size){ return sqlite3_realloc(old, size); } diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 2ecb0e7a3..6465245ca 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -30,7 +30,7 @@ ** the version number) and changes its name to "sqlite3.h" as ** part of the build process. ** -** @(#) $Id: sqlite.h.in,v 1.236 2007/08/22 00:39:20 drh Exp $ +** @(#) $Id: sqlite.h.in,v 1.237 2007/08/22 20:18:22 drh Exp $ */ #ifndef _SQLITE3_H_ #define _SQLITE3_H_ @@ -1070,8 +1070,8 @@ char *sqlite3_snprintf(int,char*,const char*, ...); ** SQLite. The application that links against SQLite is ** expected to provide its own implementation. */ -void *sqlite3_malloc(unsigned int); -void *sqlite3_realloc(void*, unsigned int); +void *sqlite3_malloc(int); +void *sqlite3_realloc(void*, int); void sqlite3_free(void*); /* diff --git a/src/sqlite3ext.h b/src/sqlite3ext.h index 4da2ca2a0..55520aeb5 100644 --- a/src/sqlite3ext.h +++ b/src/sqlite3ext.h @@ -15,7 +15,7 @@ ** as extensions by SQLite should #include this file instead of ** sqlite3.h. ** -** @(#) $Id: sqlite3ext.h,v 1.13 2007/08/16 10:09:03 danielk1977 Exp $ +** @(#) $Id: sqlite3ext.h,v 1.14 2007/08/22 20:18:22 drh Exp $ */ #ifndef _SQLITE3EXT_H_ #define _SQLITE3EXT_H_ @@ -102,7 +102,7 @@ struct sqlite3_api_routines { sqlite_int64 (*last_insert_rowid)(sqlite3*); const char * (*libversion)(void); int (*libversion_number)(void); - void *(*malloc)(unsigned int); + void *(*malloc)(int); char * (*mprintf)(const char*,...); int (*open)(const char*,sqlite3**); int (*open16)(const void*,sqlite3**); @@ -110,7 +110,7 @@ struct sqlite3_api_routines { int (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**); void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*); void (*progress_handler)(sqlite3*,int,int(*)(void*),void*); - void *(*realloc)(void*,unsigned int); + void *(*realloc)(void*,int); int (*reset)(sqlite3_stmt*pStmt); void (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*)); void (*result_double)(sqlite3_context*,double); diff --git a/src/tclsqlite.c b/src/tclsqlite.c index d953f9a71..5a65ebe50 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -12,7 +12,7 @@ ** A TCL Interface to SQLite. Append this file to sqlite3.c and ** compile the whole thing to build a TCL-enabled version of SQLite. ** -** $Id: tclsqlite.c,v 1.197 2007/08/22 00:39:21 drh Exp $ +** $Id: tclsqlite.c,v 1.198 2007/08/22 20:18:22 drh Exp $ */ #include "tcl.h" #include <errno.h> @@ -2350,8 +2350,20 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ sqlite3_close(p->db); p->db = 0; } +#ifdef SQLITE_TEST + if( p->db ){ + extern int Md5_Register(sqlite3*); + if( Md5_Register(p->db)==SQLITE_NOMEM ){ + zErrMsg = sqlite3_mprintf("%s", sqlite3_errmsg(p->db)); + sqlite3_close(p->db); + p->db = 0; + } + } +#endif #ifdef SQLITE_HAS_CODEC - sqlite3_key(p->db, pKey, nKey); + if( p->db ){ + sqlite3_key(p->db, pKey, nKey); + } #endif if( p->db==0 ){ Tcl_SetResult(interp, zErrMsg, TCL_VOLATILE); @@ -2363,23 +2375,6 @@ static int DbMain(void *cd, Tcl_Interp *interp, int objc,Tcl_Obj *const*objv){ p->interp = interp; zArg = Tcl_GetStringFromObj(objv[1], 0); Tcl_CreateObjCommand(interp, zArg, DbObjCmd, (char*)p, DbDeleteCmd); - - /* If compiled with SQLITE_TEST turned on, then register the "md5sum" - ** SQL function. - */ -#ifdef SQLITE_TEST - { - extern void Md5_Register(sqlite3*); -#if 0 - int mallocfail = sqlite3_iMallocFail; - sqlite3_iMallocFail = 0; -#endif - Md5_Register(p->db); -#if 0 - sqlite3_iMallocFail = mallocfail; -#endif - } -#endif return TCL_OK; } diff --git a/src/test1.c b/src/test1.c index c250d2b36..11ffb1e23 100644 --- a/src/test1.c +++ b/src/test1.c @@ -13,7 +13,7 @@ ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test1.c,v 1.269 2007/08/22 02:56:44 drh Exp $ +** $Id: test1.c,v 1.270 2007/08/22 20:18:22 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" @@ -955,12 +955,18 @@ static int test_create_function( ** because it is not tested anywhere else. */ if( rc==SQLITE_OK ){ sqlite3_value *pVal; - pVal = sqlite3ValueNew(0); + sqlite3_mutex_enter(db->mutex); + pVal = sqlite3ValueNew(db); sqlite3ValueSetStr(pVal, -1, "x_sqlite_exec", SQLITE_UTF8, SQLITE_STATIC); - rc = sqlite3_create_function16(db, + if( db->mallocFailed ){ + rc = SQLITE_NOMEM; + }else{ + rc = sqlite3_create_function16(db, sqlite3ValueText(pVal, SQLITE_UTF16NATIVE), 1, SQLITE_UTF16, db, sqlite3ExecFunc, 0, 0); + } sqlite3ValueFree(pVal); + sqlite3_mutex_leave(db->mutex); } #endif @@ -2134,12 +2140,18 @@ static int test_collate( sqlite3_iMallocFail++; } #endif - pVal = sqlite3ValueNew(0); + sqlite3_mutex_enter(db->mutex); + pVal = sqlite3ValueNew(db); sqlite3ValueSetStr(pVal, -1, "test_collate", SQLITE_UTF8, SQLITE_STATIC); - rc = sqlite3_create_collation16(db, + if( db->mallocFailed ){ + rc = SQLITE_NOMEM; + }else{ + rc = sqlite3_create_collation16(db, sqlite3ValueText(pVal, SQLITE_UTF16NATIVE), SQLITE_UTF16BE, (void *)SQLITE_UTF16BE, val?test_collate_func:0); + } sqlite3ValueFree(pVal); + sqlite3_mutex_leave(db->mutex); } if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR; diff --git a/src/test_config.c b/src/test_config.c index 17c1c584b..1fda2fc32 100644 --- a/src/test_config.c +++ b/src/test_config.c @@ -16,7 +16,7 @@ ** The focus of this file is providing the TCL testing layer ** access to compile-time constants. ** -** $Id: test_config.c,v 1.11 2007/08/21 10:44:16 drh Exp $ +** $Id: test_config.c,v 1.12 2007/08/22 20:18:22 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" @@ -59,6 +59,12 @@ static void set_options(Tcl_Interp *interp){ Tcl_SetVar2(interp, "sqlite_options", "lfs", "1", TCL_GLOBAL_ONLY); #endif +#ifdef SQLITE_MEMDEBUG + Tcl_SetVar2(interp, "sqlite_options", "memdebug", "1", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "memdebug", "0", TCL_GLOBAL_ONLY); +#endif + #ifdef SQLITE_OMIT_ALTERTABLE Tcl_SetVar2(interp, "sqlite_options", "altertable", "0", TCL_GLOBAL_ONLY); #else diff --git a/src/test_md5.c b/src/test_md5.c index 77c8f5523..fe00cff3f 100644 --- a/src/test_md5.c +++ b/src/test_md5.c @@ -382,7 +382,7 @@ static void md5finalize(sqlite3_context *context){ DigestToBase16(digest, zBuf); sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT); } -void Md5_Register(sqlite3 *db){ - sqlite3_create_function(db, "md5sum", -1, SQLITE_UTF8, 0, 0, - md5step, md5finalize); +int Md5_Register(sqlite3 *db){ + return sqlite3_create_function(db, "md5sum", -1, SQLITE_UTF8, 0, 0, + md5step, md5finalize); } diff --git a/src/tokenize.c b/src/tokenize.c index 5005fe1b5..7134c599f 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -15,7 +15,7 @@ ** individual tokens and sends those tokens one-by-one over to the ** parser for analysis. ** -** $Id: tokenize.c,v 1.134 2007/08/21 10:44:16 drh Exp $ +** $Id: tokenize.c,v 1.135 2007/08/22 20:18:22 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -401,6 +401,7 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){ i = 0; pEngine = sqlite3ParserAlloc((void*(*)(size_t))sqlite3_malloc); if( pEngine==0 ){ + db->mallocFailed = 1; return SQLITE_NOMEM; } assert( pParse->sLastToken.dyn==0 ); diff --git a/src/trigger.c b/src/trigger.c index 785e57e43..252dd7b46 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -265,7 +265,8 @@ void sqlite3FinishTrigger( pDel = sqlite3HashInsert(&db->aDb[iDb].pSchema->trigHash, pTrig->name, strlen(pTrig->name), pTrig); if( pDel ){ - assert( db->mallocFailed && pDel==pTrig ); + assert( pDel==pTrig ); + db->mallocFailed = 1; goto triggerfinish_cleanup; } n = strlen(pTrig->table) + 1; @@ -356,11 +357,12 @@ TriggerStep *sqlite3TriggerInsertStep( Select *pSelect, /* A SELECT statement that supplies values */ int orconf /* The conflict algorithm (OE_Abort, OE_Replace, etc.) */ ){ - TriggerStep *pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep)); + TriggerStep *pTriggerStep; assert(pEList == 0 || pSelect == 0); - assert(pEList != 0 || pSelect != 0); + assert(pEList != 0 || pSelect != 0 || db->mallocFailed); + pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep)); if( pTriggerStep ){ pTriggerStep->op = TK_INSERT; pTriggerStep->pSelect = pSelect; diff --git a/src/vdbemem.c b/src/vdbemem.c index 71d7ecd52..3e3c89005 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -908,7 +908,7 @@ sqlite3_value *sqlite3ValueNew(sqlite3 *db){ p->flags = MEM_Null; p->type = SQLITE_NULL; p->db = db; - }else{ + }else if( db ){ db->mallocFailed = 1; } return p; |