From dc9d6ce103251a827eacde12399418b8dd55ca47 Mon Sep 17 00:00:00 2001
From: "D. Richard Hipp" <drh@hwaci.com>
Date: Tue, 8 Jan 2019 14:28:02 +0000
Subject: [PATCH 0723/1009] Fix a possible memory leak when trying to UPDATE a
 corrupt RTREE index.

https://github.com/mackyle/sqlite/commit/dc9d6ce103251a827eacde12399418b8dd55ca47

---
 ext/rtree/rtree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c
index ea44ffe..83d1b82 100644
--- a/ext/rtree/rtree.c
+++ b/ext/rtree/rtree.c
@@ -717,7 +717,6 @@ static int nodeAcquire(
       pNode->pNext = 0;
       rc = sqlite3_blob_read(pRtree->pNodeBlob, pNode->zData,
                              pRtree->iNodeSize, 0);
-      nodeReference(pParent);
     }
   }
 
@@ -748,6 +747,7 @@ static int nodeAcquire(
 
   if( rc==SQLITE_OK ){
     if( pNode!=0 ){
+      nodeReference(pParent);
       nodeHashInsert(pRtree, pNode);
     }else{
       rc = SQLITE_CORRUPT_VTAB;
-- 
1.8.3.1

