From ee13669126e4a2c3ed8b86aa03d723a87d6a2de7 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Wed, 7 Apr 2010 13:59:02 +0400 Subject: [PATCH] Bug #52165: Assertion failed: file .\dtoa.c, line 465 The failing assertion was written with the assumption that a NULL string can never be passed to my_strtod(). However, an empty string may be passed under some circumstances by passing str == NULL and *end == NULL. Fixed the assertion to take the above case into account. mysql-test/r/func_misc.result: Added a test case for bug #52165. mysql-test/t/func_misc.test: Added a test case for bug #52165. strings/dtoa.c: Fixed the assertion in my_strtod() to take the case of 'str == NULL && *end == NULL' into account. --- mysql-test/r/func_misc.result | 9 +++++++++ mysql-test/t/func_misc.test | 11 +++++++++++ strings/dtoa.c | 4 +++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index d4c1aef4054..e21e7903459 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -336,4 +336,13 @@ End of 5.0 tests select connection_id() > 0; connection_id() > 0 1 +# +# Bug #52165: Assertion failed: file .\dtoa.c, line 465 +# +CREATE TABLE t1 (a SET('a'), b INT); +INSERT INTO t1 VALUES ('', 0); +SELECT COALESCE(a) = COALESCE(b) FROM t1; +COALESCE(a) = COALESCE(b) +1 +DROP TABLE t1; End of tests diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index 43cc6de6649..a60eb9cf845 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -467,4 +467,15 @@ select NAME_CONST('_id',1234) as id; select connection_id() > 0; +--echo # +--echo # Bug #52165: Assertion failed: file .\dtoa.c, line 465 +--echo # + +CREATE TABLE t1 (a SET('a'), b INT); +INSERT INTO t1 VALUES ('', 0); + +SELECT COALESCE(a) = COALESCE(b) FROM t1; + +DROP TABLE t1; + --echo End of tests diff --git a/strings/dtoa.c b/strings/dtoa.c index 88e0d9272a8..75a05be2c56 100644 --- a/strings/dtoa.c +++ b/strings/dtoa.c @@ -462,7 +462,9 @@ double my_strtod(const char *str, char **end, int *error) { char buf[DTOA_BUFF_SIZE]; double res; - DBUG_ASSERT(str != NULL && end != NULL && *end != NULL && error != NULL); + DBUG_ASSERT(end != NULL && ((str != NULL && *end != NULL) || + (str == NULL && *end == NULL)) && + error != NULL); res= my_strtod_int(str, end, error, buf, sizeof(buf)); return (*error == 0) ? res : (res < 0 ? -DBL_MAX : DBL_MAX);