aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2003-07-30 12:34:12 +0000
committerdrh <drh@noemail.net>2003-07-30 12:34:12 +0000
commit4305d10360ab7b6fba381b9e783e14503a513b58 (patch)
tree8264abdc1e8c4b4ab70c21bd8694eec3a9fad656 /src/expr.c
parenta76c82eb0de11673f9b810acdbdbb25ae5cd7d74 (diff)
downloadsqlite-4305d10360ab7b6fba381b9e783e14503a513b58.tar.gz
sqlite-4305d10360ab7b6fba381b9e783e14503a513b58.zip
The {quote: SrcList} object was not being expanded correctly by a call to
sqliteSrcListAppend() if the {quote: SrcList} had previously been duplicated by a call to sqliteSrcListDup(). Ticket #416. This check-in fixes that problem by keeping a separate nAlloc field on {quote: SrcList}. A similar change is made to {quote: IdList} and {quote: ExprList} to avoid future problems. (CVS 1067) FossilOrigin-Name: da6273255471673841fdcadc688aeac80722e130
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/expr.c b/src/expr.c
index 7f3f96f60..804e751b7 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.97 2003/07/20 01:16:47 drh Exp $
+** $Id: expr.c,v 1.98 2003/07/30 12:34:12 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -160,7 +160,7 @@ ExprList *sqliteExprListDup(ExprList *p){
if( p==0 ) return 0;
pNew = sqliteMalloc( sizeof(*pNew) );
if( pNew==0 ) return 0;
- pNew->nExpr = p->nExpr;
+ pNew->nExpr = pNew->nAlloc = p->nExpr;
pNew->a = sqliteMalloc( p->nExpr*sizeof(p->a[0]) );
if( pNew->a==0 ) return 0;
for(i=0; i<p->nExpr; i++){
@@ -189,7 +189,7 @@ SrcList *sqliteSrcListDup(SrcList *p){
nByte = sizeof(*p) + (p->nSrc>0 ? sizeof(p->a[0]) * (p->nSrc-1) : 0);
pNew = sqliteMalloc( nByte );
if( pNew==0 ) return 0;
- pNew->nSrc = p->nSrc;
+ pNew->nSrc = pNew->nAlloc = p->nSrc;
for(i=0; i<p->nSrc; i++){
pNew->a[i].zDatabase = sqliteStrDup(p->a[i].zDatabase);
pNew->a[i].zName = sqliteStrDup(p->a[i].zName);
@@ -209,7 +209,7 @@ IdList *sqliteIdListDup(IdList *p){
if( p==0 ) return 0;
pNew = sqliteMalloc( sizeof(*pNew) );
if( pNew==0 ) return 0;
- pNew->nId = p->nId;
+ pNew->nId = pNew->nAlloc = p->nId;
pNew->a = sqliteMalloc( p->nId*sizeof(p->a[0]) );
if( pNew->a==0 ) return 0;
for(i=0; i<p->nId; i++){
@@ -253,11 +253,12 @@ ExprList *sqliteExprListAppend(ExprList *pList, Expr *pExpr, Token *pName){
sqliteExprDelete(pExpr);
return 0;
}
+ pList->nAlloc = 0;
}
- if( (pList->nExpr & 7)==0 ){
- int n = pList->nExpr + 8;
+ if( pList->nAlloc<=pList->nExpr ){
struct ExprList_item *a;
- a = sqliteRealloc(pList->a, n*sizeof(pList->a[0]));
+ pList->nAlloc = pList->nAlloc*2 + 4;
+ a = sqliteRealloc(pList->a, pList->nAlloc*sizeof(pList->a[0]));
if( a==0 ){
sqliteExprDelete(pExpr);
return pList;