Commit d499851b authored by Sergey Glukhov's avatar Sergey Glukhov

Bug#11766112 59151:UNINITIALIZED VALUES IN EXTRACT_DATE_TIME WITH STR_TO_DATE(SPACE(..) ...

Valgrind warining happens due to missing
'end of the string' check. The fix is to
check if we reached the end of the string.


mysql-test/r/func_time.result:
  test case
mysql-test/t/func_time.test:
  test case
sql/item_timefunc.cc:
  check if we reached the end of
  the string after leading spaces skipping.
parent f1b638d3
......@@ -1375,4 +1375,10 @@ Warning 1292 Truncated incorrect time value: ''
Warning 1292 Truncated incorrect time value: ''
Warning 1292 Truncated incorrect time value: ''
DROP TABLE t1;
#
# Bug#11766112 59151:UNINITIALIZED VALUES IN EXTRACT_DATE_TIME WITH STR_TO_DATE(SPACE(..) ...
#
SELECT STR_TO_DATE(SPACE(2),'1');
STR_TO_DATE(SPACE(2),'1')
0000-00-00
End of 5.1 tests
......@@ -881,4 +881,10 @@ INSERT INTO t1 VALUES (''),('');
SELECT COUNT(*) FROM t1 GROUP BY TIME_TO_SEC(a);
DROP TABLE t1;
--echo #
--echo # Bug#11766112 59151:UNINITIALIZED VALUES IN EXTRACT_DATE_TIME WITH STR_TO_DATE(SPACE(..) ...
--echo #
SELECT STR_TO_DATE(SPACE(2),'1');
--echo End of 5.1 tests
......@@ -294,8 +294,8 @@ static bool extract_date_time(DATE_TIME_FORMAT *format,
for (; ptr != end && val != val_end; ptr++)
{
/* Skip pre-space between each argument */
while (val != val_end && my_isspace(cs, *val))
val++;
if ((val+= cs->cset->scan(cs, val, val_end, MY_SEQ_SPACES)) >= val_end)
break;
if (*ptr == '%' && ptr+1 != end)
{
......
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