diff options
author | bar@bar.myoffice.izhnet.ru <> | 2007-03-29 10:36:28 +0500 |
---|---|---|
committer | bar@bar.myoffice.izhnet.ru <> | 2007-03-29 10:36:28 +0500 |
commit | 306af7f4bcd97c670d07e6b564bc8226d178bb40 (patch) | |
tree | 5d4d235372a724d63bd49d2393180f9aa441f5c8 /strings | |
parent | 3099b103ce96b77af251a48cb3d979a8737f9c8d (diff) | |
parent | d5c66804431f4df36ae32154592ba8a952ed8a8e (diff) | |
download | mariadb-git-306af7f4bcd97c670d07e6b564bc8226d178bb40.tar.gz |
Merge mysql.com:/home/bar/mysql-5.0.b27079
into mysql.com:/home/bar/mysql-5.1-new-rpl
Diffstat (limited to 'strings')
-rw-r--r-- | strings/ctype-uca.c | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 1292d7f5ede..1263882846d 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -6744,7 +6744,7 @@ typedef struct my_uca_scanner_handler_st int (*next)(my_uca_scanner *scanner); } my_uca_scanner_handler; -static uint16 nochar[]= {0}; +static uint16 nochar[]= {0,0}; #ifdef HAVE_CHARSET_ucs2 @@ -6769,13 +6769,32 @@ static void my_uca_scanner_init_ucs2(my_uca_scanner *scanner, CHARSET_INFO *cs __attribute__((unused)), const uchar *str, uint length) { - /* Note, no needs to initialize scanner->wbeg */ - scanner->sbeg= str; - scanner->send= str + length - 2; scanner->wbeg= nochar; - scanner->uca_length= cs->sort_order; - scanner->uca_weight= cs->sort_order_big; - scanner->contractions= cs->contractions; + if (length) + { + scanner->sbeg= str; + scanner->send= str + length - 2; + scanner->uca_length= cs->sort_order; + scanner->uca_weight= cs->sort_order_big; + scanner->contractions= cs->contractions; + return; + } + + /* + Sometimes this function is called with + str=NULL and length=0, which should be + considered as an empty string. + + The above initialization is unsafe for such cases, + because scanner->send is initialized to (NULL-2), which is 0xFFFFFFFE. + Then we fall into an endless loop in my_uca_scanner_next_ucs2(). + + Do special initialization for the case when length=0. + Initialize scanner->sbeg to an address greater than scanner->send. + Next call of my_uca_scanner_next_ucs2() will correctly return with -1. + */ + scanner->sbeg= (uchar*) &nochar[1]; + scanner->send= (uchar*) &nochar[0]; } |