Commit 2dfc6c44 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-33729 UBSAN negation of -X cannot be represented in type 'long long int';...

MDEV-33729 UBSAN negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_strntoll_mb2_or_mb4

The problem was introduced by MDEV-30879.
The function my_strntoll_8bit() was correctly changed by MDEV-30879.
The function my_strntoll_mb2_or_mb4() was not.

Applying the missing change to my_strntoll_mb2_or_mb4().
parent d2c9d86e
......@@ -3024,3 +3024,10 @@ HEX(DATE_FORMAT(TIME'11:22:33',@format))
#
# End of 10.4 tests
#
#
# MDEV-33729 UBSAN negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_strntoll_mb2_or_mb4
#
SET NAMES utf8mb3, character_set_connection=utf32;
SELECT CONV('-AzL8n0Y58m8', -62, -10);
CONV('-AzL8n0Y58m8', -62, -10)
-9223372036854775808
......@@ -1168,3 +1168,10 @@ SELECT HEX(DATE_FORMAT(TIME'11:22:33',@format));
--echo #
--enable_service_connection
--echo #
--echo # MDEV-33729 UBSAN negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_strntoll_mb2_or_mb4
--echo #
SET NAMES utf8mb3, character_set_connection=utf32;
SELECT CONV('-AzL8n0Y58m8', -62, -10);
......@@ -504,8 +504,12 @@ my_strntoll_mb2_or_mb4(CHARSET_INFO *cs,
if (negative)
{
if (res > (ulonglong) LONGLONG_MIN)
if (res >= (ulonglong) LONGLONG_MIN)
{
if (res == (ulonglong) LONGLONG_MIN)
return LONGLONG_MIN;
overflow = 1;
}
}
else if (res > (ulonglong) LONGLONG_MAX)
overflow = 1;
......
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