diff options
Diffstat (limited to 'sql/strfunc.cc')
-rw-r--r-- | sql/strfunc.cc | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/sql/strfunc.cc b/sql/strfunc.cc index 48c77c7c99f..a5a64c065ce 100644 --- a/sql/strfunc.cc +++ b/sql/strfunc.cc @@ -265,27 +265,22 @@ uint check_word(TYPELIB *lib, const char *val, const char *end, */ -uint strconvert(CHARSET_INFO *from_cs, const char *from, +uint strconvert(CHARSET_INFO *from_cs, const char *from, uint from_length, CHARSET_INFO *to_cs, char *to, uint to_length, uint *errors) { int cnvres; my_wc_t wc; char *to_start= to; uchar *to_end= (uchar*) to + to_length - 1; + const uchar *from_end= (const uchar*) from + from_length; my_charset_conv_mb_wc mb_wc= from_cs->cset->mb_wc; my_charset_conv_wc_mb wc_mb= to_cs->cset->wc_mb; uint error_count= 0; while (1) { - /* - Using 'from + 10' is safe: - - it is enough to scan a single character in any character set. - - if remaining string is shorter than 10, then mb_wc will return - with error because of unexpected '\0' character. - */ if ((cnvres= (*mb_wc)(from_cs, &wc, - (uchar*) from, (uchar*) from + 10)) > 0) + (uchar*) from, from_end)) > 0) { if (!wc) break; |