mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.0.0219: ubsan reports errors for overflow
Problem: Ubsan reports errors for integer overflow. Solution: Define macros for minimum and maximum values. Select an expression based on the value. (Mike Williams)
This commit is contained in:
15
src/eval.c
15
src/eval.c
@@ -4109,21 +4109,12 @@ eval6(
|
||||
{
|
||||
if (n2 == 0) /* give an error message? */
|
||||
{
|
||||
#ifdef FEAT_NUM64
|
||||
if (n1 == 0)
|
||||
n1 = -0x7fffffffffffffffLL - 1; /* similar to NaN */
|
||||
n1 = VARNUM_MIN; /* similar to NaN */
|
||||
else if (n1 < 0)
|
||||
n1 = -0x7fffffffffffffffLL;
|
||||
n1 = -VARNUM_MAX;
|
||||
else
|
||||
n1 = 0x7fffffffffffffffLL;
|
||||
#else
|
||||
if (n1 == 0)
|
||||
n1 = -0x7fffffffL - 1L; /* similar to NaN */
|
||||
else if (n1 < 0)
|
||||
n1 = -0x7fffffffL;
|
||||
else
|
||||
n1 = 0x7fffffffL;
|
||||
#endif
|
||||
n1 = VARNUM_MAX;
|
||||
}
|
||||
else
|
||||
n1 = n1 / n2;
|
||||
|
Reference in New Issue
Block a user