diff options
author | drh <> | 2021-04-19 15:05:27 +0000 |
---|---|---|
committer | drh <> | 2021-04-19 15:05:27 +0000 |
commit | 60b95335e2031461c3d2f9332d308e4875ed92ae (patch) | |
tree | 24735db47316d18ae4bb63ced535d666502b835a /src/select.c | |
parent | 0a746cc528744f771b76b366cae87f2285951490 (diff) | |
download | sqlite-60b95335e2031461c3d2f9332d308e4875ed92ae.tar.gz sqlite-60b95335e2031461c3d2f9332d308e4875ed92ae.zip |
In the query flattener, avoid invalidating an expression if an OOM occurs.
This prevents problems in higher-level routines that might not check for
the OOM after processing a subquery.
dbsqlfuzz fb70fa8602421f87673e0670b0712ff2b5240ea0
FossilOrigin-Name: d564d8882ef18b55ebf93e838426b485281c7ebe3a9b321a2f984ed0f229cc25
Diffstat (limited to 'src/select.c')
-rw-r--r-- | src/select.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/select.c b/src/select.c index a543702bf..176115689 100644 --- a/src/select.c +++ b/src/select.c @@ -3627,10 +3627,11 @@ static Expr *substExpr( } testcase( ExprHasProperty(pCopy, EP_Subquery) ); pNew = sqlite3ExprDup(db, pCopy, 0); - if( pNew && pSubst->isLeftJoin ){ + if( pNew==0 ) return pExpr; + if( pSubst->isLeftJoin ){ ExprSetProperty(pNew, EP_CanBeNull); } - if( pNew && ExprHasProperty(pExpr,EP_FromJoin) ){ + if( ExprHasProperty(pExpr,EP_FromJoin) ){ sqlite3SetJoinExpr(pNew, pExpr->iRightJoinTable); } sqlite3ExprDelete(db, pExpr); @@ -3638,15 +3639,13 @@ static Expr *substExpr( /* Ensure that the expression now has an implicit collation sequence, ** just as it did when it was a column of a view or sub-query. */ - if( pExpr ){ - if( pExpr->op!=TK_COLUMN && pExpr->op!=TK_COLLATE ){ - CollSeq *pColl = sqlite3ExprCollSeq(pSubst->pParse, pExpr); - pExpr = sqlite3ExprAddCollateString(pSubst->pParse, pExpr, - (pColl ? pColl->zName : "BINARY") - ); - } - ExprClearProperty(pExpr, EP_Collate); + if( pExpr->op!=TK_COLUMN && pExpr->op!=TK_COLLATE ){ + CollSeq *pColl = sqlite3ExprCollSeq(pSubst->pParse, pExpr); + pExpr = sqlite3ExprAddCollateString(pSubst->pParse, pExpr, + (pColl ? pColl->zName : "BINARY") + ); } + ExprClearProperty(pExpr, EP_Collate); } } }else{ |