From 77b8a94d7a767291f90d57f0e667b421c5f41037 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 17 Jan 2005 22:35:53 +0100 Subject: [PATCH 1/2] make the code to look safe, not only be safe --- ndb/src/common/util/strdup.c | 4 ++-- sql/log.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ndb/src/common/util/strdup.c b/ndb/src/common/util/strdup.c index afe2306427e..d8f4d99bd28 100644 --- a/ndb/src/common/util/strdup.c +++ b/ndb/src/common/util/strdup.c @@ -21,8 +21,8 @@ char * strdup(const char *s){ void *p2; - p2 = malloc(strlen(s)+1); - strcpy(p2, s); + if ((p2 = malloc(strlen(s)+1))) + strcpy(p2, s); return p2; } #endif diff --git a/sql/log.cc b/sql/log.cc index 4504b286506..38844877f1b 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2247,9 +2247,9 @@ void print_buffer_to_nt_eventlog(enum loglevel level, char *buff, DBUG_ENTER("print_buffer_to_nt_eventlog"); buffptr= buff; - if (length > (uint)(buffLen-4)) + if (length > (uint)(buffLen-5)) { - char *newBuff= new char[length + 4]; + char *newBuff= new char[length + 5]; strcpy(newBuff, buff); buffptr= newBuff; } From f003895df9f562018ba47e5f7af2eae03d937368 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 18 Jan 2005 11:27:38 +0100 Subject: [PATCH 2/2] myisam/ft_boolean_search.c -trunc* bug - don't increase yweaks in this case myisam/ft_boolean_search.c: -trunc* bug - don't increase yweaks in this case mysql-test/r/fulltext.result: -trunc* bug - don't increase yweaks in this case mysql-test/t/fulltext.test: -trunc* bug - don't increase yweaks in this case --- myisam/ft_boolean_search.c | 11 ++++++----- mysql-test/r/fulltext.result | 3 +++ mysql-test/t/fulltext.test | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index ffc7e1bf104..aab3854dd34 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -345,11 +345,12 @@ static void _ftb_init_index_search(FT_INFO *ftb) if (ftbe->flags & FTB_FLAG_NO || /* 2 */ ftbe->up->ythresh - ftbe->up->yweaks >1) /* 1 */ { - FTB_EXPR *top_ftbe=ftbe->up->up; + FTB_EXPR *top_ftbe=ftbe->up; ftbw->docid[0]=HA_OFFSET_ERROR; - for (ftbe=ftbw->up; ftbe != top_ftbe; ftbe=ftbe->up) - if (!(ftbe->flags & FTB_FLAG_NO)) - ftbe->yweaks++; + for (ftbe=(FTB_EXPR *)ftbw; + ftbe != top_ftbe && !(ftbe->flags & FTB_FLAG_NO); + ftbe=ftbe->up) + ftbe->up->yweaks++; ftbe=0; break; } @@ -363,7 +364,7 @@ static void _ftb_init_index_search(FT_INFO *ftb) else reset_tree(& ftb->no_dupes); } - + if (_ft2_search(ftb, ftbw, 1)) return; } diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index 7acc8a2d23f..a042248ba34 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -148,6 +148,9 @@ select * from t1 where MATCH a,b AGAINST ('+(support collections) +foobar*' IN B a b select * from t1 where MATCH a,b AGAINST ('+(+(support collections)) +foobar*' IN BOOLEAN MODE); a b +select * from t1 where MATCH a,b AGAINST ('+collections -supp* -foobar*' IN BOOLEAN MODE); +a b +Full-text indexes are called collections select * from t1 where MATCH a,b AGAINST ('"xt indexes"' IN BOOLEAN MODE); a b select * from t1 where MATCH a,b AGAINST('"space model' IN BOOLEAN MODE); diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 008e965297f..62dcecaff68 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -67,6 +67,7 @@ select * from t1 where MATCH a,b AGAINST ('"xt indexes"' IN BOOLEAN MODE); select * from t1 where MATCH a,b AGAINST ('+(support collections) +foobar*' IN BOOLEAN MODE); select * from t1 where MATCH a,b AGAINST ('+(+(support collections)) +foobar*' IN BOOLEAN MODE); +select * from t1 where MATCH a,b AGAINST ('+collections -supp* -foobar*' IN BOOLEAN MODE); select * from t1 where MATCH a,b AGAINST ('"xt indexes"' IN BOOLEAN MODE); # bug#2708, bug#3870 crash