]> granicus.if.org Git - vim/commitdiff
patch 8.2.3470: crash with error in :catch and also in :finally v8.2.3470
authorBram Moolenaar <Bram@vim.org>
Mon, 4 Oct 2021 17:52:19 +0000 (18:52 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 4 Oct 2021 17:52:19 +0000 (18:52 +0100)
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
src/testdir/test_trycatch.vim
src/version.c

index 259cf670cc6e0fd518065742f6dd4cca6126f0e6..503a3ae02aa383482dffef386b128172e2a36951 100644 (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
index 052fab7bb7d3cbd71723c90545e1aae04f8ae8ed..ac12671da6a860e5ce3613883cdd269282694a3f 100644 (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
index d15495ec5d37f685a5b04e5b903aff6404bfbe5d..23b0c3682c7e18c2d65379ad11fc10cbdd5ba14d 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3470,
 /**/
     3469,
 /**/