sqlite/0029-Handle-SQL-NULL-values-without-crashing-in-the-fts5-.patch

49 lines
1.3 KiB
Diff
Raw Normal View History

2019-09-30 11:17:27 -04:00
From 88ea6ea1ee2b7c93120857c65c882144c9f4ce71 Mon Sep 17 00:00:00 2001
From: Dan Kennedy <danielk1977@gmail.com>
Date: Tue, 15 Jan 2019 18:14:27 +0000
Subject: [PATCH 0773/1009] Handle SQL NULL values without crashing in the fts5
snippet() and highlight() functions.
https://github.com/mackyle/sqlite/commit/88ea6ea1ee2b7c93120857c65c882144c9f4ce71
---
ext/fts5/fts5_aux.c | 2 +-
ext/fts5/test/fts5ak.test | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/ext/fts5/fts5_aux.c b/ext/fts5/fts5_aux.c
index f884ddb..7d4f3e6 100644
--- a/ext/fts5/fts5_aux.c
+++ b/ext/fts5/fts5_aux.c
@@ -136,7 +136,7 @@ static void fts5HighlightAppend(
HighlightContext *p,
const char *z, int n
){
- if( *pRc==SQLITE_OK ){
+ if( *pRc==SQLITE_OK && z ){
if( n<0 ) n = (int)strlen(z);
p->zOut = sqlite3_mprintf("%z%.*s", p->zOut, n, z);
if( p->zOut==0 ) *pRc = SQLITE_NOMEM;
diff --git a/ext/fts5/test/fts5ak.test b/ext/fts5/test/fts5ak.test
index cab0ae2..0a3cd6a78 100644
--- a/ext/fts5/test/fts5ak.test
+++ b/ext/fts5/test/fts5ak.test
@@ -144,6 +144,14 @@ do_execsql_test 3.1 {
{[a b c d e]}
}
+do_execsql_test 3.2 {
+ SELECT highlight(ft, 0, NULL, NULL) FROM ft WHERE ft MATCH 'a+b+c AND c+d+e';
+} {
+ {a b c x c d e}
+ {a b c c d e}
+ {a b c d e}
+}
+
}
finish_test
--
1.8.3.1