]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Avoid segfaults when inserted NULL values into FTS1. (CVS 3447)
authordrh <drh@noemail.net>
Thu, 28 Sep 2006 11:41:41 +0000 (11:41 +0000)
committerdrh <drh@noemail.net>
Thu, 28 Sep 2006 11:41:41 +0000 (11:41 +0000)
FossilOrigin-Name: 165645d30115f3171fc45489823f85639fe2bfcd

ext/fts1/fts1.c
ext/fts1/fts1_tokenizer1.c
manifest
manifest.uuid
test/fts1a.test

index 6a30fcf8df086936cebfa5ae630c5b0844e49b05..47ce5f8591fa96215a6d144c84fa2da67595c738 100644 (file)
@@ -2627,6 +2627,7 @@ static int parseQuery(
 ){
   int iInput, inPhrase = 0;
 
+  if( zInput==0 ) nInput = 0;
   if( nInput<0 ) nInput = strlen(zInput);
   pQuery->nTerms = 0;
   pQuery->pTerms = NULL;
index 7fdce719fd4915598177c2d75640321b367fdf49..f1849730c2c80b2527d35de0012abcee4a65452c 100644 (file)
@@ -101,7 +101,13 @@ static int simpleOpen(
 
   c = (simple_tokenizer_cursor *) malloc(sizeof(simple_tokenizer_cursor));
   c->pInput = pInput;
-  c->nBytes = nBytes<0 ? (int) strlen(pInput) : nBytes;
+  if( pInput==0 ){
+    c->nBytes = 0;
+  }else if( nBytes<0 ){
+    c->nBytes = (int)strlen(pInput);
+  }else{
+    c->nBytes = nBytes;
+  }
   c->iOffset = 0;                 /* start tokenizing at the beginning */
   c->iToken = 0;
   c->pToken = NULL;               /* no space allocated, yet. */
index e3e6424e0bcb66d804cf64d44beff9dfd712b5c8..3a46379121d6a2ca30a368bfebf81bfde1efb3fe 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sto\sthe\sprevious\scheck-in.\s(CVS\s3446)
-D 2006-09-26T00:37:11
+C Avoid\ssegfaults\swhen\sinserted\sNULL\svalues\sinto\sFTS1.\s(CVS\s3447)
+D 2006-09-28T11:41:41
 F Makefile.in cabd42d34340f49260bc2a7668c38eba8d4cfd99
 F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -21,12 +21,12 @@ F ext/README.txt 913a7bd3f4837ab14d7e063304181787658b14e1
 F ext/fts1/README.txt 20ac73b006a70bcfd80069bdaf59214b6cf1db5e
 F ext/fts1/ft_hash.c 3927bd880e65329bdc6f506555b228b28924921b
 F ext/fts1/ft_hash.h 1a35e654a235c2c662d3ca0dfc3138ad60b8b7d5
-F ext/fts1/fts1.c 6efbbd6fb17ad9744f058db66fab15883ed69703
+F ext/fts1/fts1.c 5cb7829d331502a3151d6648cadd358ac97b5161
 F ext/fts1/fts1.h 6060b8f62c1d925ea8356cb1a6598073eb9159a6
 F ext/fts1/fts1_hash.c 3196cee866edbebb1c0521e21672e6d599965114
 F ext/fts1/fts1_hash.h 957d378355ed29f672cd5add012ce8b088a5e089
 F ext/fts1/fts1_tokenizer.h 12c0e7ad83120aff1f86ca848149f96f61da738b
-F ext/fts1/fts1_tokenizer1.c 79877389420de24956cb651169550ac16488e5f6
+F ext/fts1/fts1_tokenizer1.c 3c96905873123f5bf76e01e6adb17177f4f2268d
 F ext/fts1/fulltext.c d935e600d87bc86b7d64f55c7520ea41d6034c5c
 F ext/fts1/fulltext.h 08525a47852d1d62a0be81d3fc3fe2d23b094efd
 F ext/fts1/simple_tokenizer.c 1844d72f7194c3fd3d7e4173053911bf0661b70d
@@ -190,7 +190,7 @@ F test/enc3.test 890508efff6677345e93bf2a8adb0489b30df030
 F test/expr.test c78843f730ccbe973d0c2ad1c99978f936893131
 F test/fkey1.test 153004438d51e6769fb1ce165f6313972d6263ce
 F test/format4.test bf3bed3b13c63abfb3cfec232597a319a31d0bcc
-F test/fts1a.test 54fd9451c00fb91074d5abdc207b05dcba6d2d65
+F test/fts1a.test 8fa66282a2a297faebdab76279c1693eb7920a3b
 F test/fts1b.test 5d8a01aefbecc8b7442b36c94c05eb7a845462d5
 F test/fts1c.test a57cb192d59ddacba64d17c326ff99393c181dc6
 F test/func.test 0ed54b5aeaad319f68016c033acfebef56f5874a
@@ -399,7 +399,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
 F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
 F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P 46ac1ac2d10cf2f1ebfb8dd4bb9a2ccffd85e816
-R 7c25623524f618ab81020ca3d377d6dd
+P 944d5f812004e2dc0065fce267accf8907235a50
+R a3b9f1ec905300375312507d7a2e50ec
 U drh
-Z 72c5b22a712991b46cad5f091360e410
+Z e44db4ed3c8a0588eb2a24973c8a730d
index 99d40599b4439511a6a5d89359cc96e0768304bd..3144d7b27c5ca7c315df55b56aa1b098ac7f12b3 100644 (file)
@@ -1 +1 @@
-944d5f812004e2dc0065fce267accf8907235a50
\ No newline at end of file
+165645d30115f3171fc45489823f85639fe2bfcd
\ No newline at end of file
index 5b8cc9d280e924958f78e20a85bc5bb310abe604..5286fd71af64e3a568982f4e409f73cba01c2f98 100644 (file)
@@ -11,7 +11,7 @@
 # This file implements regression tests for SQLite library.  The
 # focus of this script is testing the FTS1 module.
 #
-# $Id: fts1a.test,v 1.2 2006/09/13 12:36:09 drh Exp $
+# $Id: fts1a.test,v 1.3 2006/09/28 11:41:41 drh Exp $
 #
 
 set testdir [file dirname $argv0]
@@ -156,4 +156,19 @@ do_test fts1a-4.3 {
   execsql {SELECT rowid FROM t1 WHERE content MATCH 'three OR "one two"'}
 } {3 4 5 6 7 11 12 13 14 15 19 20 21 22 23 27 28 29 30 31}
 
+# Test the ability to handle NULL content
+#
+do_test fts1a-5.1 {
+  execsql {INSERT INTO t1(content) VALUES(NULL)}
+} {}
+do_test fts1a-5.2 {
+  set rowid [db last_insert_rowid]
+  execsql {SELECT content FROM t1 WHERE rowid=$rowid}
+} {{}}
+do_test fts1a-5.3 {
+  execsql {SELECT rowid FROM t1 WHERE content MATCH NULL}
+} {}
+
+
+
 finish_test