diff options
author | drh <drh@noemail.net> | 2017-09-17 19:45:28 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2017-09-17 19:45:28 +0000 |
commit | 97258194a2eb054822fbb8ff6cf4d285458f5513 (patch) | |
tree | 682207084271c1b88c3ff480b154269d08f334dd /src/expr.c | |
parent | 559656196bed206a08c9d07ae5610f1ea95243de (diff) | |
download | sqlite-97258194a2eb054822fbb8ff6cf4d285458f5513.tar.gz sqlite-97258194a2eb054822fbb8ff6cf4d285458f5513.zip |
Do not make the assumption (as check-in [4da49a95c0f07] incorrectly did) that
the ExprList returned by sqlite3ExprListDup() would never be passed into
sqlite3ExprListAppend(). Include a new test case that shows this sometimes
does happen.
FossilOrigin-Name: 29227d00a9999f0f28a0b55ef70183799a667c3b9d81d2e5ac0ab1840bef98b1
Diffstat (limited to 'src/expr.c')
-rw-r--r-- | src/expr.c | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/src/expr.c b/src/expr.c index 405103f21..f3326d02e 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1302,14 +1302,9 @@ ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p, int flags){ Expr *pPriorSelectCol = 0; assert( db!=0 ); if( p==0 ) return 0; - pNew = sqlite3DbMallocRawNN(db, - sizeof(*pNew)+sizeof(pNew->a[0])*(p->nExpr-1) ); + pNew = sqlite3DbMallocRawNN(db, sqlite3DbMallocSize(db, p)); if( pNew==0 ) return 0; pNew->nExpr = p->nExpr; - /* After being duplicated, the ExprList may not be expanded again using - ** Append() because Append() assumes that the number of slots in - ** ExprList.a[] is a power of 2 */ - VVA_ONLY( pNew->bFixedSize = 1 ); pItem = pNew->a; pOldItem = p->a; for(i=0; i<p->nExpr; i++, pItem++, pOldItem++){ @@ -1482,14 +1477,12 @@ ExprList *sqlite3ExprListAppend( struct ExprList_item *pItem; sqlite3 *db = pParse->db; assert( db!=0 ); - assert( pList==0 || pList->bFixedSize==0 ); if( pList==0 ){ pList = sqlite3DbMallocRawNN(db, sizeof(ExprList) ); if( pList==0 ){ goto no_mem; } pList->nExpr = 0; - VVA_ONLY( pList->bFixedSize = 0 ); }else if( (pList->nExpr & (pList->nExpr-1))==0 ){ ExprList *pNew; pNew = sqlite3DbRealloc(db, pList, |