diff options
author | Alexander Barkov <bar@mariadb.org> | 2015-09-17 19:49:49 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2015-09-17 19:49:49 +0400 |
commit | f789158ddfa90933678dc927a05719ba692d0854 (patch) | |
tree | beac7388d10f90f565f30e77d4beaaac5d8fee5d /sql | |
parent | c83810f402d65c7dee2cf15fd38b8bf6281610f0 (diff) | |
download | mariadb-git-f789158ddfa90933678dc927a05719ba692d0854.tar.gz |
The patch for MDEV-8466 revealed a bug in str2my_decimal,
which did not return a correct "end_of_num" pointer in case
of character sets with mbminlen>1 (ucs2, utf16, utf16le, utf32).
The bug caused sporadic test failures on BuildBot,
as well "uninitialized memory read" errors in valgrind builds.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/my_decimal.cc | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc index 91455c7cb84..37d4dd25473 100644 --- a/sql/my_decimal.cc +++ b/sql/my_decimal.cc @@ -243,21 +243,21 @@ int str2my_decimal(uint mask, const char *from, uint length, const char **end_ptr) { int err; - char buff[STRING_BUFFER_USUAL_SIZE]; - String tmp(buff, sizeof(buff), &my_charset_bin); if (charset->mbminlen > 1) { + StringBuffer<STRING_BUFFER_USUAL_SIZE> tmp; uint dummy_errors; tmp.copy(from, length, charset, &my_charset_latin1, &dummy_errors); - from= tmp.ptr(); - length= tmp.length(); - charset= &my_charset_bin; + char *end= (char*) tmp.end(); + err= string2decimal(tmp.ptr(), (decimal_t*) decimal_value, &end); + *end_ptr= from + charset->mbminlen * (size_t) (end - tmp.ptr()); + } + else + { + char *end= (char*) from + length; + err= string2decimal(from, (decimal_t*) decimal_value, &end); + *end_ptr= end; } - char *end= (char*) from + length; - err= string2decimal((char *)from, (decimal_t*) decimal_value, &end); - if (charset->mbminlen > 1) - end= (char *) from + charset->mbminlen * (size_t) (end - buff); - *end_ptr= end; check_result_and_overflow(mask, err, decimal_value); return err; } |