diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-10-19 18:34:48 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-19 18:34:48 +0800 |
commit | a0961659770ca41edcb5a6dcf28e7c7492eb60f0 (patch) | |
tree | f6259a11fa53bf2166db37b31206def27076bd5d /src/nvim/ex_eval.c | |
parent | ae7020c667b5314fe832d2a8897fb16d57194bdf (diff) | |
download | rneovim-a0961659770ca41edcb5a6dcf28e7c7492eb60f0.tar.gz rneovim-a0961659770ca41edcb5a6dcf28e7c7492eb60f0.tar.bz2 rneovim-a0961659770ca41edcb5a6dcf28e7c7492eb60f0.zip |
vim-patch:9.0.2050: Vim9: crash with deferred function call and exception (#25715)
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: vim/vim#13376
closes: vim/vim#13377
https://github.com/vim/vim/commit/c59c1e0d88651a71ece7366e418f1253abbe2a28
The change in check_due_timer() is N/A as Nvim calls timer callbacks on
the main loop.
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/ex_eval.c')
-rw-r--r-- | src/nvim/ex_eval.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index c656f785c9..7412757726 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -661,6 +661,35 @@ static void finish_exception(except_T *excp) discard_exception(excp, true); } +/// Save the current exception state in "estate" +void exception_state_save(exception_state_T *estate) +{ + estate->estate_current_exception = current_exception; + estate->estate_did_throw = did_throw; + estate->estate_need_rethrow = need_rethrow; + estate->estate_trylevel = trylevel; +} + +/// Restore the current exception state from "estate" +void exception_state_restore(exception_state_T *estate) +{ + if (current_exception == NULL) { + current_exception = estate->estate_current_exception; + } + did_throw |= estate->estate_did_throw; + need_rethrow |= estate->estate_need_rethrow; + trylevel |= estate->estate_trylevel; +} + +/// Clear the current exception state +void exception_state_clear(void) +{ + current_exception = NULL; + did_throw = false; + need_rethrow = false; + trylevel = 0; +} + // Flags specifying the message displayed by report_pending. #define RP_MAKE 0 #define RP_RESUME 1 |