diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-05-22 22:07:52 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-05-22 22:07:52 +0100 |
commit | 68e64d2c1735f2a39afa8a0475ae29bedb116684 (patch) | |
tree | fc30407cfebef2a874ca6a83f4351ceef025d657 | |
parent | 5b529230f144028b67ed1d59207af098c18a1858 (diff) | |
download | vim-git-68e64d2c1735f2a39afa8a0475ae29bedb116684.tar.gz |
patch 8.2.5006: asan warns for undefined behaviorv8.2.5006
Problem: Asan warns for undefined behavior.
Solution: Cast the shifted value to unsigned.
-rw-r--r-- | src/eval.c | 2 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9execute.c | 2 | ||||
-rw-r--r-- | src/vim9expr.c | 3 |
4 files changed, 6 insertions, 3 deletions
diff --git a/src/eval.c b/src/eval.c index 7f9095466..1aa0eaec7 100644 --- a/src/eval.c +++ b/src/eval.c @@ -3089,7 +3089,7 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg) rettv->vval.v_number = 0; else if (type == EXPR_LSHIFT) rettv->vval.v_number = - rettv->vval.v_number << var2.vval.v_number; + (uvarnumber_T)rettv->vval.v_number << var2.vval.v_number; else rettv->vval.v_number = (uvarnumber_T)rettv->vval.v_number >> var2.vval.v_number; diff --git a/src/version.c b/src/version.c index f0ccd2086..43390faa6 100644 --- a/src/version.c +++ b/src/version.c @@ -735,6 +735,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 5006, +/**/ 5005, /**/ 5004, diff --git a/src/vim9execute.c b/src/vim9execute.c index 5410aa284..217a97797 100644 --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -4091,7 +4091,7 @@ exec_instructions(ectx_T *ectx) case EXPR_LSHIFT: if (arg2 > MAX_LSHIFT_BITS) res = 0; else - res = arg1 << arg2; + res = (uvarnumber_T)arg1 << arg2; break; case EXPR_RSHIFT: if (arg2 > MAX_LSHIFT_BITS) res = 0; diff --git a/src/vim9expr.c b/src/vim9expr.c index 6fb32cb6d..a52f2c7e2 100644 --- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -2716,7 +2716,8 @@ compile_expr5(char_u **arg, cctx_T *cctx, ppconst_T *ppconst) if (tv2->vval.v_number > MAX_LSHIFT_BITS) tv1->vval.v_number = 0; else if (type == EXPR_LSHIFT) - tv1->vval.v_number = tv1->vval.v_number << tv2->vval.v_number; + tv1->vval.v_number = + (uvarnumber_T)tv1->vval.v_number << tv2->vval.v_number; else tv1->vval.v_number = (uvarnumber_T)tv1->vval.v_number >> tv2->vval.v_number; |