patch 9.0.2050: Vim9: crash with deferred function call and exception
Problem: Vim9: crash with deferred function call and exception
Solution: Save and restore exception state
Crash when a deferred function is called after an exception and another
exception is thrown
closes: #13376
closes: #13377
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
diff --git a/src/structs.h b/src/structs.h
index f7f3b2e..a1a94b0 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -1088,6 +1088,19 @@
except_T *exception; // exception value
};
+/*
+ * Exception state that is saved and restored when calling timer callback
+ * functions and deferred functions.
+ */
+typedef struct exception_state_S exception_state_T;
+struct exception_state_S
+{
+ except_T *estate_current_exception;
+ int estate_did_throw;
+ int estate_need_rethrow;
+ int estate_trylevel;
+};
+
#ifdef FEAT_SYN_HL
// struct passed to in_id_list()
struct sp_syn