mirror of
https://github.com/MariaDB/server.git
synced 2026-05-17 20:37:12 +02:00
MDEV-31221 UBSAN runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int' in my_strtoll10_utf32
The code in my_strtoll10_mb2 and my_strtoll10_utf32 could hit undefinite behavior by negation of LONGLONG_MIN. Fixing to avoid this. Also, fixing my_strtoll10() in the same style. The previous reduction produced a redundant warning on CAST(_latin1'-9223372036854775808' AS SIGNED)
This commit is contained in:
parent
841dc07ee1
commit
9ac8172ac3
8 changed files with 51 additions and 1 deletions
|
|
@ -1011,6 +1011,8 @@ end4:
|
|||
{
|
||||
if (li > MAX_NEGATIVE_NUMBER)
|
||||
goto overflow;
|
||||
if (li == MAX_NEGATIVE_NUMBER) // Avoid undefinite behavior in negation
|
||||
return LONGLONG_MIN;
|
||||
return -((longlong) li);
|
||||
}
|
||||
return (longlong) li;
|
||||
|
|
@ -2574,6 +2576,8 @@ end4:
|
|||
{
|
||||
if (li > MAX_NEGATIVE_NUMBER)
|
||||
goto overflow;
|
||||
if (li == MAX_NEGATIVE_NUMBER) // Avoid undefinite behavior in negation
|
||||
return LONGLONG_MIN;
|
||||
return -((longlong) li);
|
||||
}
|
||||
return (longlong) li;
|
||||
|
|
|
|||
|
|
@ -241,8 +241,10 @@ end4:
|
|||
*endptr= (char*) s;
|
||||
if (negative)
|
||||
{
|
||||
if (li >= MAX_NEGATIVE_NUMBER) // Avoid undefined behavior
|
||||
if (li > MAX_NEGATIVE_NUMBER)
|
||||
goto overflow;
|
||||
if (li == MAX_NEGATIVE_NUMBER) // Avoid undefined behavior
|
||||
return LONGLONG_MIN;
|
||||
return -((longlong) li);
|
||||
}
|
||||
return (longlong) li;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue