diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-05-06 11:27:52 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-05-06 11:27:52 +0100 |
commit | 434725cc4cbbadafc82954178f55864741455cdb (patch) | |
tree | 949a4101dbe6bf3d4f16b9c8d844598ee5c24b7b | |
parent | 3e79427803927be42409e9e50c0a308526b83656 (diff) | |
download | vim-git-434725cc4cbbadafc82954178f55864741455cdb.tar.gz |
patch 8.2.4880: Vim9: misplaced elseif causes invalid memory accessv8.2.4880
Problem: Vim9: misplaced elseif causes invalid memory access.
Solution: Check cs_idx not to be negative.
-rw-r--r-- | src/ex_eval.c | 11 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/ex_eval.c b/src/ex_eval.c index 7b4ac1750..f3e2ca28c 100644 --- a/src/ex_eval.c +++ b/src/ex_eval.c @@ -1124,10 +1124,13 @@ ex_else(exarg_T *eap) skip = TRUE; } - // Variables declared in the previous block can no longer be - // used. Needs to be done before setting "cs_flags". - leave_block(cstack); - enter_block(cstack); + if (cstack->cs_idx >= 0) + { + // Variables declared in the previous block can no longer be + // used. Needs to be done before setting "cs_flags". + leave_block(cstack); + enter_block(cstack); + } // if skipping or the ":if" was TRUE, reset ACTIVE, otherwise set it if (skip || cstack->cs_flags[cstack->cs_idx] & CSF_TRUE) diff --git a/src/version.c b/src/version.c index 5a597a8fd..848c3e642 100644 --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4880, +/**/ 4879, /**/ 4878, |