From 2fbabe31a19e10c68357884846454753ee2b4cc3 Mon Sep 17 00:00:00 2001
From: Dan Kennedy <danielk1977@gmail.com>
Date: Fri, 11 Jan 2019 21:34:25 +0000
Subject: [PATCH 0748/1009] Fix a segfault in fts3 prompted by a corrupted
 database.

https://github.com/mackyle/sqlite/commit/2fbabe31a19e10c68357884846454753ee2b4cc3

---
 ext/fts3/fts3.c        |  2 +-
 1 files changed, 1 insertions(+), 1 deletion(-)

diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c
index e168fae..5266749 100644
--- a/ext/fts3/fts3.c
+++ b/ext/fts3/fts3.c
@@ -2899,7 +2899,7 @@ static int fts3SegReaderCursor(
 
       /* If zTerm is not NULL, and this segment is not stored entirely on its
       ** root node, the range of leaves scanned can be reduced. Do this. */
-      if( iStartBlock && zTerm ){
+      if( iStartBlock && zTerm && zRoot ){
         sqlite3_int64 *pi = (isPrefix ? &iLeavesEndBlock : 0);
         rc = fts3SelectLeaf(p, zTerm, nTerm, zRoot, nRoot, &iStartBlock, pi);
         if( rc!=SQLITE_OK ) goto finished;
-- 
1.8.3.1

