61 lines
1.9 KiB
Diff
61 lines
1.9 KiB
Diff
From 6b06304c2a46e17a6dc4402eadc75ccac24da893 Mon Sep 17 00:00:00 2001
|
|
From: Ondrej Dubaj <odubaj@redhat.com>
|
|
Date: Fri, 17 Jan 2020 13:03:54 +0100
|
|
Subject: [PATCH] When an error occurs while rewriting the parser tree for
|
|
window functions in the sqlite3WindowRewrite() routine, make sure that
|
|
pParse->nErr is set, and make sure that this shuts down any subsequent code
|
|
generation that might depend on the transformations that were implemented.
|
|
This fixes a problem discovered by the Yongheng and Rui fuzzer.
|
|
|
|
---
|
|
src/expr.c | 1 +
|
|
src/vdbeaux.c | 3 ++-
|
|
src/window.c | 5 +++++
|
|
3 files changed, 8 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/expr.c b/src/expr.c
|
|
index d4eb9de..b081ca2 100644
|
|
--- a/src/expr.c
|
|
+++ b/src/expr.c
|
|
@@ -344,6 +344,7 @@ static int codeCompare(
|
|
int addr;
|
|
CollSeq *p4;
|
|
|
|
+ if( pParse->nErr ) return 0;
|
|
p4 = sqlite3BinaryCompareCollSeq(pParse, pLeft, pRight);
|
|
p5 = binaryCompareP5(pLeft, pRight, jumpIfNull);
|
|
addr = sqlite3VdbeAddOp4(pParse->pVdbe, opcode, in2, dest, in1,
|
|
diff --git a/src/vdbeaux.c b/src/vdbeaux.c
|
|
index f1496a3..b74141b 100644
|
|
--- a/src/vdbeaux.c
|
|
+++ b/src/vdbeaux.c
|
|
@@ -1160,7 +1160,8 @@ void sqlite3VdbeSetP4KeyInfo(Parse *pParse, Index *pIdx){
|
|
*/
|
|
static void vdbeVComment(Vdbe *p, const char *zFormat, va_list ap){
|
|
assert( p->nOp>0 || p->aOp==0 );
|
|
- assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed );
|
|
+ assert( p->aOp==0 || p->aOp[p->nOp-1].zComment==0 || p->db->mallocFailed
|
|
+ || p->pParse->nErr>0 );
|
|
if( p->nOp ){
|
|
assert( p->aOp );
|
|
sqlite3DbFree(p->db, p->aOp[p->nOp-1].zComment);
|
|
diff --git a/src/window.c b/src/window.c
|
|
index f5deae9..56c0145 100644
|
|
--- a/src/window.c
|
|
+++ b/src/window.c
|
|
@@ -843,6 +843,11 @@ int sqlite3WindowRewrite(Parse *pParse, Select *p){
|
|
if( db->mallocFailed ) rc = SQLITE_NOMEM;
|
|
}
|
|
|
|
+ if( rc && pParse->nErr==0 ){
|
|
+ assert( pParse->db->mallocFailed );
|
|
+ return SQLITE_NOMEM;
|
|
+ }
|
|
+
|
|
return rc;
|
|
}
|
|
|
|
--
|
|
2.19.1
|
|
|