diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-01-22 18:34:57 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-01-22 18:34:57 +0100 |
commit | 7a40ea2138102545848ea86a361f1b8dec7552b5 (patch) | |
tree | 28c03360f9bb2de0d7454f50ffccc1f33c75fe54 /src/evalfunc.c | |
parent | 2b2207ba69c6b009e466a36eef0644ca723e16d3 (diff) | |
download | vim-git-7a40ea2138102545848ea86a361f1b8dec7552b5.tar.gz |
patch 8.0.0219: ubsan reports errors for overflowv8.0.0219
Problem: Ubsan reports errors for integer overflow.
Solution: Define macros for minimum and maximum values. Select an
expression based on the value. (Mike Williams)
Diffstat (limited to 'src/evalfunc.c')
-rw-r--r-- | src/evalfunc.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/evalfunc.c b/src/evalfunc.c index da2235455..9ebd2df41 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -3304,21 +3304,12 @@ f_float2nr(typval_T *argvars, typval_T *rettv) if (get_float_arg(argvars, &f) == OK) { -# ifdef FEAT_NUM64 - if (f < -0x7fffffffffffffffLL) - rettv->vval.v_number = -0x7fffffffffffffffLL; - else if (f > 0x7fffffffffffffffLL) - rettv->vval.v_number = 0x7fffffffffffffffLL; + if (f < -VARNUM_MAX) + rettv->vval.v_number = -VARNUM_MAX; + else if (f > VARNUM_MAX) + rettv->vval.v_number = VARNUM_MAX; else rettv->vval.v_number = (varnumber_T)f; -# else - if (f < -0x7fffffff) - rettv->vval.v_number = -0x7fffffff; - else if (f > 0x7fffffff) - rettv->vval.v_number = 0x7fffffff; - else - rettv->vval.v_number = (varnumber_T)f; -# endif } } |