From 4c4a25727fbcbb1677ae1be787b61116c16710fa Mon Sep 17 00:00:00 2001 From: drh <> Date: Tue, 6 Apr 2021 12:50:24 +0000 Subject: [PATCH] Earlier detection and handling of OOM problems. dbsqlfuzz 39f2963ea5559aa3a16e24e0e3cb42aac85a7371. FossilOrigin-Name: 8d46df73132e46abb32b9dc129b6beb978d34dac3d372fb004ca283b0832d04c --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/expr.c | 1 + src/trigger.c | 4 ++-- src/window.c | 6 +++++- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index dbf9be839f..8aa7ec7e6a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Relax\san\sassertion\son\sthe\ssqlite3WhereEnd()\sroutine\safter\sdbsqlfuzz\sfound\na\scounter-example. -D 2021-04-05T22:42:15.909 +C Earlier\sdetection\sand\shandling\sof\sOOM\sproblems.\ndbsqlfuzz\s39f2963ea5559aa3a16e24e0e3cb42aac85a7371. +D 2021-04-06T12:50:24.393 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -494,7 +494,7 @@ F src/date.c e0632f335952b32401482d099321bbf12716b29d6e72836b53ae49683ebae4bf F src/dbpage.c 8a01e865bf8bc6d7b1844b4314443a6436c07c3efe1d488ed89e81719047833a F src/dbstat.c 3aa79fc3aed7ce906e4ea6c10e85d657299e304f6049861fe300053ac57de36c F src/delete.c 73f57a9a183532c344a3135cf8f2a5589376e39183e0b5f562d6b61b2af0f4d8 -F src/expr.c 9b03ea5c8a883dc892b5ea4f984089c911b91c0ea333be5316d64ec0100ec0f8 +F src/expr.c 4fd60d0e74795f0d083535000e2149241715e8ca3bb4a8f8ecb100427abf8eea F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007 F src/fkey.c e9063648396c58778f77583a678342fe4a9bc82436bf23c5f9f444f2df0fdaa4 F src/func.c 479f6929be027eb0210cbdde9d3529c012facf082d64a6b854a9415940761e5e @@ -608,7 +608,7 @@ F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c F src/tokenize.c 0b9c82fa628b5adce93e2bcaf935a24d43eb83344fb51551f7835526d0693fc4 F src/treeview.c 70f57a2b77e20b354724ea69b8ed1ea1df946c48296d695320c741c7d174be90 -F src/trigger.c 9ef94b525f283397f69290989eb53e2c620686e68da46fb7115fa4ca87649d9c +F src/trigger.c f8493674f5c8f103c1a2cd0616af9dca85c7058450f9fe47cacd15cf5d512d52 F src/update.c 0f5a61f0787199983530a33f6fffe4f52742f35fcdf6ccfad1078b1a8bc17723 F src/upsert.c df8f1727d62b5987c4fd302cd4d7c0c84ae57cd65683c5a34a740dfe24039235 F src/utf.c ee39565f0843775cc2c81135751ddd93eceb91a673ea2c57f61c76f288b041a0 @@ -633,7 +633,7 @@ F src/where.c 9accf968b0e75804b0e99a7500f5310e5213bc3f5a2bd6810e51da354d2cc3b5 F src/whereInt.h 446e5e8018f83358ef917cf32d8e6a86dc8430113d0b17e720f1839d3faa44c4 F src/wherecode.c 8bdc239eae3d39f9f6ace4299eeb86e1e0c56eed88b60f9c473dc85ae79f4e89 F src/whereexpr.c 4ba94b8ebbff97c658b212de6ccdb6d3a41847800bdf99e7a2a967c250269f2c -F src/window.c 038b6a0bea89932f97553aae51775d4118ac3051bb3edc0e40981b46748ad3f8 +F src/window.c 1bc737c35faf229d83d997562dfdd4d75e3cef0101b13935d227d39d581cb190 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627 F test/affinity3.test eecb0dabee4b7765a8465439d5e99429279ffba23ca74a7eae270a452799f9e7 @@ -1912,7 +1912,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 82f92d79e1901911b0ce57d0aa30d462847748159443c7db8af16e6b37e8212c -R 2e31e96ae9f36da0cd4c701dda708260 +P e6b591e76523034c41884b39d71d4b721f1df709bdafd842e2d4b4084c158ec0 +R a7fd41424a9e57e428b6b216e173390d U drh -Z 066878ec0da3f3c2bd65fbad64a4cf2b +Z dfcacbd9705f5e53a47d8fa7356aad42 diff --git a/manifest.uuid b/manifest.uuid index aea9445fec..cbdc80bdab 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e6b591e76523034c41884b39d71d4b721f1df709bdafd842e2d4b4084c158ec0 \ No newline at end of file +8d46df73132e46abb32b9dc129b6beb978d34dac3d372fb004ca283b0832d04c \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 63053547d1..4d7258959e 100644 --- a/src/expr.c +++ b/src/expr.c @@ -3389,6 +3389,7 @@ static void sqlite3ExprCodeIN( if( pParse->nErr ) goto sqlite3ExprCodeIN_finished; for(i=0; ipLeft, i); + if( pParse->db->mallocFailed ) goto sqlite3ExprCodeIN_oom_error; if( sqlite3ExprCanBeNull(p) ){ sqlite3VdbeAddOp2(v, OP_IsNull, rLhs+i, destStep2); VdbeCoverage(v); diff --git a/src/trigger.c b/src/trigger.c index 50cffc1d21..578d1e42ef 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -1147,8 +1147,8 @@ static TriggerPrg *codeRowTrigger( ** OP_Halt inserted at the end of the program. */ if( pTrigger->pWhen ){ pWhen = sqlite3ExprDup(db, pTrigger->pWhen, 0); - if( SQLITE_OK==sqlite3ResolveExprNames(&sNC, pWhen) - && db->mallocFailed==0 + if( db->mallocFailed==0 + && SQLITE_OK==sqlite3ResolveExprNames(&sNC, pWhen) ){ iEndTrigger = sqlite3VdbeMakeLabel(pSubParse); sqlite3ExprIfFalse(pSubParse, pWhen, iEndTrigger, SQLITE_JUMPIFNULL); diff --git a/src/window.c b/src/window.c index 137288af34..62cba15757 100644 --- a/src/window.c +++ b/src/window.c @@ -900,7 +900,11 @@ static ExprList *exprListAppendList( sqlite3 *db = pParse->db; Expr *pDup = sqlite3ExprDup(db, pAppend->a[i].pExpr, 0); assert( pDup==0 || !ExprHasProperty(pDup, EP_MemToken) ); - if( bIntToNull && db->mallocFailed==0 ){ + if( db->mallocFailed ){ + sqlite3ExprDelete(db, pDup); + break; + } + if( bIntToNull ){ int iDummy; Expr *pSub; for(pSub=pDup; ExprHasProperty(pSub, EP_Skip); pSub=pSub->pLeft){