0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

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)
This commit is contained in:
Bram Moolenaar
2021-10-04 18:52:19 +01:00
parent 50c5689342
commit a684a68409
3 changed files with 16 additions and 1 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -757,6 +757,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3470,
/**/
3469,
/**/