Mercurial > vim
changeset 28712:d59c8dc8be20 v8.2.4880
patch 8.2.4880: Vim9: misplaced elseif causes invalid memory access
Commit: https://github.com/vim/vim/commit/434725cc4cbbadafc82954178f55864741455cdb
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri May 6 11:27:52 2022 +0100
patch 8.2.4880: Vim9: misplaced elseif causes invalid memory access
Problem: Vim9: misplaced elseif causes invalid memory access.
Solution: Check cs_idx not to be negative.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 06 May 2022 12:30:04 +0200 |
parents | 9ef5ee193725 |
children | f608d3f98e0e |
files | src/ex_eval.c src/version.c |
diffstat | 2 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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)