Code layout fix for bug N 27079

Thanks to Gluh for suggestion.
This commit is contained in:
unknown 2007-03-29 10:32:38 +05:00
parent 6370f6226f
commit ee0475bf5d

View File

@ -6777,25 +6777,24 @@ static void my_uca_scanner_init_ucs2(my_uca_scanner *scanner,
scanner->uca_length= cs->sort_order; scanner->uca_length= cs->sort_order;
scanner->uca_weight= cs->sort_order_big; scanner->uca_weight= cs->sort_order_big;
scanner->contractions= cs->contractions; scanner->contractions= cs->contractions;
return;
} }
else
{ /*
/* Sometimes this function is called with
Sometimes this function is called with str=NULL and length=0, which should be
str=NULL and length=0, which should be considered as an empty string.
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().
The above initialization is unsafe for such cases, Do special initialization for the case when length=0.
because scanner->send is initialized to (NULL-2), which is 0xFFFFFFFE. Initialize scanner->sbeg to an address greater than scanner->send.
Then we fall into an endless loop in my_uca_scanner_next_ucs2(). Next call of my_uca_scanner_next_ucs2() will correctly return with -1.
*/
Do special initialization for the case when length=0. scanner->sbeg= (uchar*) &nochar[1];
Initialize scanner->sbeg to an address greater than scanner->send. scanner->send= (uchar*) &nochar[0];
Next call of my_uca_scanner_next_ucs2() will correctly return with -1.
*/
scanner->sbeg= (uchar*) &nochar[1];
scanner->send= (uchar*) &nochar[0];
}
} }