From c76494d8b745065793a604a5aefc0cb2b792b01e Mon Sep 17 00:00:00 2001 From: Gabriel Cruz Date: Sat, 30 Mar 2019 18:28:19 -0300 Subject: [PATCH] vim-patch:8.0.0705: check did_throw before discarding exception #9808 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. https://github.com/vim/vim/commit/cae24be4a808d60313913cc6feea6c2bee2e2a42 --- src/nvim/ex_eval.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 7f7851f078..5b2a1c5c51 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -569,10 +569,12 @@ static void discard_exception(except_T *excp, int was_finished) */ void discard_current_exception(void) { - discard_exception(current_exception, false); + if (current_exception != NULL) { + discard_exception(current_exception, false); + current_exception = NULL; + } // Note: all globals manipulated here should be saved/restored in // try_enter/try_leave. - current_exception = NULL; need_rethrow = false; } @@ -1766,6 +1768,7 @@ void enter_cleanup(cleanup_T *csp) */ if (current_exception || need_rethrow) { csp->exception = current_exception; + current_exception = NULL; } else { csp->exception = NULL; if (did_emsg) {