0
0
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:
Bram Moolenaar
2017-01-22 18:34:57 +01:00
parent 2b2207ba69
commit 7a40ea2138
6 changed files with 59 additions and 31 deletions

View File

@@ -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;