From: Alexander Barkov Date: January 18 2011 7:17am Subject: bzr push into mysql-trunk branch (alexander.barkov:3525 to 3526) Bug#59145 List-Archive: http://lists.mysql.com/commits/129026 X-Bug: 59145 Message-Id: <201101180717.p0I7Htms000510@bar.myoffice.izhnet.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3526 Alexander Barkov 2011-01-18 Bug#59145 valgrind warnings for uninitialized values in my_strtoll10_mb2 @ mysql-test/r/ctype_ucs.result Adding test @ mysql-test/t/ctype_ucs.test Adding test @ strings/ctype-ucs2.c "wc" was not initialized in case of empty string. - Removing redundant loop condition in for - on end-of-string the loop will break by "goto". - Making "goto" condition stricter (just in case) modified: mysql-test/r/ctype_ucs.result mysql-test/t/ctype_ucs.test strings/ctype-ucs2.c 3525 Alexander Barkov 2011-01-18 [merge] Merging from 5.5. modified: mysql-test/r/xml.result mysql-test/t/xml.test strings/xml.c === modified file 'mysql-test/r/ctype_ucs.result' --- a/mysql-test/r/ctype_ucs.result 2010-12-02 17:47:56 +0000 +++ b/mysql-test/r/ctype_ucs.result 2011-01-18 07:16:49 +0000 @@ -4620,5 +4620,18 @@ ae 00610065 drop table t1; "END ctype_german.inc" # +# Bug#59145 valgrind warnings for uninitialized values in my_strtoll10_mb2 +# +SET NAMES latin1; +SELECT CONVERT(CHAR(NULL USING ucs2), UNSIGNED); +CONVERT(CHAR(NULL USING ucs2), UNSIGNED) +0 +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '' +DO IFNULL(CHAR(NULL USING ucs2), ''); +DO CAST(CONVERT('' USING ucs2) AS UNSIGNED); +Warnings: +Warning 1292 Truncated incorrect INTEGER value: '' +# # End of 5.6 tests # === modified file 'mysql-test/t/ctype_ucs.test' --- a/mysql-test/t/ctype_ucs.test 2010-06-25 12:00:49 +0000 +++ b/mysql-test/t/ctype_ucs.test 2011-01-18 07:16:49 +0000 @@ -765,5 +765,13 @@ SET collation_connection=ucs2_german2_ci --source include/ctype_german.inc --echo # +--echo # Bug#59145 valgrind warnings for uninitialized values in my_strtoll10_mb2 +--echo # +SET NAMES latin1; +SELECT CONVERT(CHAR(NULL USING ucs2), UNSIGNED); +DO IFNULL(CHAR(NULL USING ucs2), ''); +DO CAST(CONVERT('' USING ucs2) AS UNSIGNED); + +--echo # --echo # End of 5.6 tests --echo # === modified file 'strings/ctype-ucs2.c' --- a/strings/ctype-ucs2.c 2010-12-17 11:28:59 +0000 +++ b/strings/ctype-ucs2.c 2011-01-18 07:16:49 +0000 @@ -725,12 +725,18 @@ my_strtoll10_mb2(CHARSET_INFO *cs, /* If fixed length string */ if (endptr) { - /* Make sure string length is even */ + /* + Make sure string length is even. + Odd length indicates a bug in the caller. + Assert in debug, round in production. + */ + DBUG_ASSERT((*endptr - s) % 2 == 0); end= s + ((*endptr - s) / 2) * 2; - for ( ; s < end; ) /* Skip leading spaces and tabs */ + + for ( ; ; ) /* Skip leading spaces and tabs */ { res= cs->cset->mb_wc(cs, &wc, (const uchar *) s, (const uchar *) end); - if (res < 0) + if (res <= 0) goto no_conv; s+= res; if (wc != ' ' && wc != '\t') No bundle (reason: useless for push emails).