Skip to content

Commit

Permalink
The patch for MDEV-8466 revealed a bug in str2my_decimal,
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Alexander Barkov committed Sep 17, 2015
1 parent c83810f commit f789158
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions sql/my_decimal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit f789158

Please sign in to comment.