aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/build.c1
-rw-r--r--src/prepare.c10
-rw-r--r--src/select.c2
3 files changed, 12 insertions, 1 deletions
diff --git a/src/build.c b/src/build.c
index b1812753a..4c7d85c4e 100644
--- a/src/build.c
+++ b/src/build.c
@@ -1325,6 +1325,7 @@ void sqlite3AddReturning(Parse *pParse, ExprList *pList){
pRet->pReturnEL = pList;
sqlite3ParserAddCleanup(pParse,
(void(*)(sqlite3*,void*))sqlite3DeleteReturning, pRet);
+ testcase( pParse->earlyCleanup );
if( db->mallocFailed ) return;
pRet->retTrig.zName = RETURNING_TRIGGER_NAME;
pRet->retTrig.op = TK_RETURNING;
diff --git a/src/prepare.c b/src/prepare.c
index d79495d2c..eb4627f0d 100644
--- a/src/prepare.c
+++ b/src/prepare.c
@@ -589,13 +589,21 @@ void sqlite3ParserReset(Parse *pParse){
** sqlite3ParserReset(), which reduces the total CPU cycle count.
**
** If a memory allocation error occurs, then the cleanup happens immediately.
-** When eithr SQLITE_DEBUG or SQLITE_COVERAGE_TEST are defined, the
+** When either SQLITE_DEBUG or SQLITE_COVERAGE_TEST are defined, the
** pParse->earlyCleanup flag is set in that case. Calling code show verify
** that test cases exist for which this happens, to guard against possible
** use-after-free errors following an OOM. The preferred way to do this is
** to immediately follow the call to this routine with:
**
** testcase( pParse->earlyCleanup );
+**
+** This routine returns a copy of its pPtr input (the third parameter)
+** except if an early cleanup occurs, in which case it returns NULL. So
+** another way to check for early cleanup is to check the return value.
+** Or, stop using the pPtr parameter with this call and use only its
+** return value thereafter. Something like this:
+**
+** pObj = sqlite3ParserAddCleanup(pParse, destructor, pObj);
*/
void *sqlite3ParserAddCleanup(
Parse *pParse, /* Destroy when this Parser finishes */
diff --git a/src/select.c b/src/select.c
index 2b73b2f4d..beb5c1e3b 100644
--- a/src/select.c
+++ b/src/select.c
@@ -6046,6 +6046,7 @@ int sqlite3Select(
sqlite3ParserAddCleanup(pParse,
(void(*)(sqlite3*,void*))sqlite3ExprListDelete,
p->pOrderBy);
+ testcase( pParse->earlyCleanup );
p->pOrderBy = 0;
}
p->selFlags &= ~SF_Distinct;
@@ -6666,6 +6667,7 @@ int sqlite3Select(
if( pAggInfo ){
sqlite3ParserAddCleanup(pParse,
(void(*)(sqlite3*,void*))agginfoFree, pAggInfo);
+ testcase( pParse->earlyCleanup );
}
if( db->mallocFailed ){
goto select_end;