From a684a684096ecef3fbaee39c573b47423235d6b1 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 4 Oct 2021 18:52:19 +0100 Subject: [PATCH] patch 8.2.3470: crash with error in :catch and also in :finally Problem: Crash with error in :catch and also in :finally. Solution: Only discard an exception if there is one. (closes #8954) --- src/ex_eval.c | 3 ++- src/testdir/test_trycatch.vim | 12 ++++++++++++ src/version.c | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/ex_eval.c b/src/ex_eval.c index 259cf670c..503a3ae02 100644 --- a/src/ex_eval.c +++ b/src/ex_eval.c @@ -2374,7 +2374,8 @@ cleanup_conditionals( default: if (cstack->cs_flags[idx] & CSF_FINALLY) { - if (cstack->cs_pending[idx] & CSTP_THROW) + if ((cstack->cs_pending[idx] & CSTP_THROW) + && cstack->cs_exception[idx] != NULL) { // Cancel the pending exception. This is in the // finally clause, so that the stack of the diff --git a/src/testdir/test_trycatch.vim b/src/testdir/test_trycatch.vim index 052fab7bb..ac12671da 100644 --- a/src/testdir/test_trycatch.vim +++ b/src/testdir/test_trycatch.vim @@ -2273,6 +2273,18 @@ func Test_user_command_function_call_with_endtry() call delete('XtestThrow') endfunc +func ThisWillFail() + try + if x | endif + catch + for l in [] + finally +endfunc + +func Test_error_in_catch_and_finally() + call assert_fails('call ThisWillFail()', ['E121:', 'E600:']) +endfunc + " Modeline {{{1 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker diff --git a/src/version.c b/src/version.c index d15495ec5..23b0c3682 100644 --- a/src/version.c +++ b/src/version.c @@ -757,6 +757,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 3470, /**/ 3469, /**/ -- 2.50.1