Blame SOURCES/sqlite-3.26.0-CVE-2019-19924.patch

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