aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_eval.c
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2021-10-08 21:05:38 +0100
committerzeertzjq <zeertzjq@outlook.com>2022-04-13 21:28:05 +0800
commitfc954d0a61ca8952bdcd05f66fe07ae2a4ccb712 (patch)
tree6be84cfc98563dfb506c9e05a6194358ea575e61 /src/nvim/ex_eval.c
parent789558d365a3134a33cdf4f1f3cc5e77efcad687 (diff)
downloadrneovim-fc954d0a61ca8952bdcd05f66fe07ae2a4ccb712.tar.gz
rneovim-fc954d0a61ca8952bdcd05f66fe07ae2a4ccb712.tar.bz2
rneovim-fc954d0a61ca8952bdcd05f66fe07ae2a4ccb712.zip
vim-patch:8.2.3486: illegal memory access with invalid sequence of commands
Problem: Illegal memory access with invalid sequence of commands. Solution: Do not call leave_block() when not in a try block. (closes vim/vim#8966) Reset did_emsg so that exception is shown as an error. https://github.com/vim/vim/commit/cce81e9673fe8d056e8eef310d9919620eccb2f2 Vim9script is N/A, which includes leave_block.
Diffstat (limited to 'src/nvim/ex_eval.c')
-rw-r--r--src/nvim/ex_eval.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c
index b5456e8982..f4aaab5c43 100644
--- a/src/nvim/ex_eval.c
+++ b/src/nvim/ex_eval.c
@@ -1083,7 +1083,7 @@ void ex_endwhile(exarg_T *eap)
if (cstack->cs_looplevel <= 0 || cstack->cs_idx < 0) {
eap->errmsg = err;
} else {
- fl = cstack->cs_flags[cstack->cs_idx];
+ fl = cstack->cs_flags[cstack->cs_idx];
if (!(fl & csf)) {
// If we are in a ":while" or ":for" but used the wrong endloop
// command, do not rewind to the next enclosing ":for"/":while".
@@ -1575,6 +1575,7 @@ void ex_endtry(exarg_T *eap)
if (!(cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) {
eap->errmsg = get_end_emsg(cstack);
+
// Find the matching ":try" and report what's missing.
idx = cstack->cs_idx;
do {
@@ -1594,6 +1595,9 @@ void ex_endtry(exarg_T *eap)
if (current_exception) {
discard_current_exception();
}
+
+ // report eap->errmsg, also when there already was an error
+ did_emsg = false;
} else {
idx = cstack->cs_idx;
@@ -1664,8 +1668,10 @@ void ex_endtry(exarg_T *eap)
*/
(void)cleanup_conditionals(cstack, CSF_TRY | CSF_SILENT, TRUE);
- --cstack->cs_idx;
- --cstack->cs_trylevel;
+ if (cstack->cs_idx >= 0 && (cstack->cs_flags[cstack->cs_idx] & CSF_TRY)) {
+ cstack->cs_idx--;
+ }
+ cstack->cs_trylevel--;
if (!skip) {
report_resume_pending(pending,