]> granicus.if.org Git - vim/commitdiff
patch 8.2.4880: Vim9: misplaced elseif causes invalid memory access v8.2.4880
authorBram Moolenaar <Bram@vim.org>
Fri, 6 May 2022 10:27:52 +0000 (11:27 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 6 May 2022 10:27:52 +0000 (11:27 +0100)
Problem:    Vim9: misplaced elseif causes invalid memory access.
Solution:   Check cs_idx not to be negative.

src/ex_eval.c
src/version.c

index 7b4ac1750dd37e254a5db32e1a7624f571eea4f2..f3e2ca28cfe3702101c7e285b36d97c2c08ee0d0 100644 (file)
@@ -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)
index 5a597a8fd80bae552182c5f40ad92dc9446ab2eb..848c3e6423a0d388867f2937d0022e6b45093d42 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4880,
 /**/
     4879,
 /**/