diff options
author | drh <drh@noemail.net> | 2008-12-08 13:42:36 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2008-12-08 13:42:36 +0000 |
commit | 555f8de7ef2202781d1e5e929c7d2c1a4045a59c (patch) | |
tree | 25e5a8b6423dd165bdcdc82689e2a9a26d508dcc /src | |
parent | bbce338412255f7aa5539c2bc6575f954d1ccae4 (diff) | |
download | sqlite-555f8de7ef2202781d1e5e929c7d2c1a4045a59c.tar.gz sqlite-555f8de7ef2202781d1e5e929c7d2c1a4045a59c.zip |
Fix a segfault associated with the column cache that occurs on nested VIEWs.
Ticket #3527. (CVS 5989)
FossilOrigin-Name: 490138a2012fcb4c859e1cf12a35e314ec1060d2
Diffstat (limited to 'src')
-rw-r--r-- | src/expr.c | 10 | ||||
-rw-r--r-- | src/sqliteInt.h | 3 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/expr.c b/src/expr.c index 0796c8dba..10db73964 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.405 2008/12/05 15:24:17 drh Exp $ +** $Id: expr.c,v 1.406 2008/12/08 13:42:36 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> @@ -1725,10 +1725,14 @@ void sqlite3ExprHardCopy(Parse *pParse, int iReg, int nReg){ static int codeAlias(Parse *pParse, int iAlias, Expr *pExpr, int target){ sqlite3 *db = pParse->db; int iReg; - if( pParse->aAlias==0 ){ - pParse->aAlias = sqlite3DbMallocZero(db, + if( pParse->nAliasAlloc<pParse->nAlias ){ + pParse->aAlias = sqlite3DbReallocOrFree(db, pParse->aAlias, sizeof(pParse->aAlias[0])*pParse->nAlias ); + testcase( db->mallocFailed && pParse->nAliasAlloc>0 ); if( db->mallocFailed ) return 0; + memset(&pParse->aAlias[pParse->nAliasAlloc], 0, + (pParse->nAlias-pParse->nAliasAlloc)*sizeof(pParse->aAlias[0])); + pParse->nAliasAlloc = pParse->nAlias; } assert( iAlias>0 && iAlias<=pParse->nAlias ); iReg = pParse->aAlias[iAlias-1]; diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 5758aa407..adf051033 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -11,7 +11,7 @@ ************************************************************************* ** Internal interface definitions for SQLite. ** -** @(#) $Id: sqliteInt.h,v 1.802 2008/12/05 17:17:08 drh Exp $ +** @(#) $Id: sqliteInt.h,v 1.803 2008/12/08 13:42:36 drh Exp $ */ #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ @@ -1752,6 +1752,7 @@ struct Parse { int nVarExprAlloc; /* Number of allocated slots in apVarExpr[] */ Expr **apVarExpr; /* Pointers to :aaa and $aaaa wildcard expressions */ int nAlias; /* Number of aliased result set columns */ + int nAliasAlloc; /* Number of allocated slots for aAlias[] */ int *aAlias; /* Register used to hold aliased result */ u8 explain; /* True if the EXPLAIN flag is found on the query */ Token sErrToken; /* The token at which the error occurred */ |