diff src/ex_eval.c @ 11645:50f2a4ad1cfa v8.0.0705

patch 8.0.0705: crash when there is an error in a timer callback commit https://github.com/vim/vim/commit/cae24be4a808d60313913cc6feea6c2bee2e2a42 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jul 10 22:12:10 2017 +0200 patch 8.0.0705: crash when there is an error in a timer callback Problem: Crash when there is an error in a timer callback. (Aron Griffis, Ozaki Kiichi) Solution: Check did_throw before discarding an exception. NULLify current_exception when no longer valid.
author Christian Brabandt <cb@256bit.org>
date Mon, 10 Jul 2017 22:15:03 +0200
parents 147f45c283e1
children 27b9a84395b5
line wrap: on
line diff
--- a/src/ex_eval.c
+++ b/src/ex_eval.c
@@ -640,8 +640,11 @@ discard_exception(except_T *excp, int wa
     void
 discard_current_exception(void)
 {
-    discard_exception(current_exception, FALSE);
-    current_exception = NULL;
+    if (current_exception != NULL)
+    {
+	discard_exception(current_exception, FALSE);
+	current_exception = NULL;
+    }
     did_throw = FALSE;
     need_rethrow = FALSE;
 }
@@ -1978,7 +1981,10 @@ enter_cleanup(cleanup_T *csp)
 	 * there is an extra instance for every call of do_cmdline(), anyway.
 	 */
 	if (did_throw || need_rethrow)
+	{
 	    csp->exception = current_exception;
+	    current_exception = NULL;
+	}
 	else
 	{
 	    csp->exception = NULL;