1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

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
This commit is contained in:
drh
2017-09-17 19:45:28 +00:00
parent 559656196b
commit 97258194a2
5 changed files with 20 additions and 20 deletions

View File

@@ -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,