Commit f789158d authored by Alexander Barkov's avatar Alexander Barkov

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.
parent c83810f4
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment