]> granicus.if.org Git - vim/commitdiff
patch 8.2.3478: still crash with error in :catch and also in :finally v8.2.3478
authorBram Moolenaar <Bram@vim.org>
Tue, 5 Oct 2021 10:22:27 +0000 (11:22 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 5 Oct 2021 10:22:27 +0000 (11:22 +0100)
Problem:    Still crash with error in :catch and also in :finally.
Solution:   Only call finish_exception() once. (closes #8954)

src/ex_eval.c
src/structs.h
src/version.c

index 503a3ae02aa383482dffef386b128172e2a36951..ee6816a396c98b69a7013055be0b20470ba0e870 100644 (file)
@@ -2401,8 +2401,12 @@ cleanup_conditionals(
            if (!(cstack->cs_flags[idx] & CSF_FINALLY))
            {
                if ((cstack->cs_flags[idx] & CSF_ACTIVE)
-                       && (cstack->cs_flags[idx] & CSF_CAUGHT))
+                       && (cstack->cs_flags[idx] & CSF_CAUGHT)
+                       && !(cstack->cs_flags[idx] & CSF_FINISHED))
+               {
                    finish_exception((except_T *)cstack->cs_exception[idx]);
+                   cstack->cs_flags[idx] |= CSF_FINISHED;
+               }
                // Stop at this try conditional - except the try block never
                // got active (because of an inactive surrounding conditional
                // or when the ":try" appeared after an error or interrupt or
index eae6cd928174dd675e1ca06bc6e4da8acc8b5855..b5889b77616d4f350bd0fe6f27d5e36235275c95 100644 (file)
@@ -943,11 +943,12 @@ typedef struct {
 # define CSF_CATCH     0x0400  // ":catch" has been seen
 # define CSF_THROWN    0x0800  // exception thrown to this try conditional
 # define CSF_CAUGHT    0x1000  // exception caught by this try conditional
-# define CSF_SILENT    0x2000  // "emsg_silent" reset by ":try"
+# define CSF_FINISHED  0x2000  // CSF_CAUGHT was handled by finish_exception()
+# define CSF_SILENT    0x4000  // "emsg_silent" reset by ":try"
 // Note that CSF_ELSE is only used when CSF_TRY and CSF_WHILE are unset
 // (an ":if"), and CSF_SILENT is only used when CSF_TRY is set.
-//
-#define CSF_FUNC_DEF   0x4000  // a function was defined in this block
+
+# define CSF_FUNC_DEF  0x8000  // a function was defined in this block
 
 /*
  * What's pending for being reactivated at the ":endtry" of this try
index e65eb8c57248d8d5772c12d10a11d4538dbbe0e5..fa64466568f91bcc6cd671f5b01f5425c40cff90 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3478,
 /**/
     3477,
 /**/