aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordrh <>2021-04-20 12:14:12 +0000
committerdrh <>2021-04-20 12:14:12 +0000
commit9da977f1a5563d983087a1d0bd85eba65f35cca2 (patch)
tree4af710ca2f1e300abd3e4bba4dd337c14ba4c210 /src/expr.c
parent8c6cb1bc6f2bb3bd814b6d4c7cd11aad4186c41d (diff)
downloadsqlite-9da977f1a5563d983087a1d0bd85eba65f35cca2.tar.gz
sqlite-9da977f1a5563d983087a1d0bd85eba65f35cca2.zip
In the sqlite3SelectDup() routine, do not do an incomplete duplication due
to OOM. This in turn requires several new NEVER() and ALWAYS() macros for unreachable branches. FossilOrigin-Name: a61c0e6b78bd39f55464fafd257e68effded64995a66e8fa2d686e8c507ebe43
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/expr.c b/src/expr.c
index d9c8af65c..bd45fbcd1 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -1648,6 +1648,14 @@ Select *sqlite3SelectDup(sqlite3 *db, Select *pDup, int flags){
if( p->pWin && db->mallocFailed==0 ) gatherSelectWindows(pNew);
#endif
pNew->selId = p->selId;
+ if( db->mallocFailed ){
+ /* Any prior OOM might have left the Select object incomplete.
+ ** Delete the whole thing rather than allow an incomplete Select
+ ** to be used by the code generator. */
+ pNew->pNext = 0;
+ sqlite3SelectDelete(db, pNew);
+ break;
+ }
*pp = pNew;
pp = &pNew->pPrior;
pNext = pNew;