comparison src/vim9execute.c @ 22621:576a69fc0066 v8.2.1859

patch 8.2.1859: Vim9: crash in unpack assignment Commit: https://github.com/vim/vim/commit/352134bbfbff4831a3f6a3383d9e2d8660016243 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Oct 17 22:04:08 2020 +0200 patch 8.2.1859: Vim9: crash in unpack assignment Problem: Vim9: crash in unpack assignment. Solution: Make sure an error message is turned into an exception. (closes #7159)
author Bram Moolenaar <Bram@vim.org>
date Sat, 17 Oct 2020 22:15:03 +0200
parents 048a3033d19c
children 672ee41a6a3b
comparison
equal deleted inserted replaced
22620:b5d68d8a5187 22621:576a69fc0066
828 int defcount = ufunc->uf_args.ga_len - argc; 828 int defcount = ufunc->uf_args.ga_len - argc;
829 sctx_T save_current_sctx = current_sctx; 829 sctx_T save_current_sctx = current_sctx;
830 int breakcheck_count = 0; 830 int breakcheck_count = 0;
831 int called_emsg_before = called_emsg; 831 int called_emsg_before = called_emsg;
832 int save_suppress_errthrow = suppress_errthrow; 832 int save_suppress_errthrow = suppress_errthrow;
833 msglist_T **saved_msg_list = NULL;
834 msglist_T *private_msg_list = NULL;
833 835
834 // Get pointer to item in the stack. 836 // Get pointer to item in the stack.
835 #define STACK_TV(idx) (((typval_T *)ectx.ec_stack.ga_data) + idx) 837 #define STACK_TV(idx) (((typval_T *)ectx.ec_stack.ga_data) + idx)
836 838
837 // Get pointer to item at the bottom of the stack, -1 is the bottom. 839 // Get pointer to item at the bottom of the stack, -1 is the bottom.
979 // Following errors are in the function, not the caller. 981 // Following errors are in the function, not the caller.
980 // Commands behave like vim9script. 982 // Commands behave like vim9script.
981 estack_push_ufunc(ufunc, 1); 983 estack_push_ufunc(ufunc, 1);
982 current_sctx = ufunc->uf_script_ctx; 984 current_sctx = ufunc->uf_script_ctx;
983 current_sctx.sc_version = SCRIPT_VERSION_VIM9; 985 current_sctx.sc_version = SCRIPT_VERSION_VIM9;
986
987 // Use a specific location for storing error messages to be converted to an
988 // exception.
989 saved_msg_list = msg_list;
990 msg_list = &private_msg_list;
984 991
985 // Do turn errors into exceptions. 992 // Do turn errors into exceptions.
986 suppress_errthrow = FALSE; 993 suppress_errthrow = FALSE;
987 994
988 // Decide where to start execution, handles optional arguments. 995 // Decide where to start execution, handles optional arguments.
2816 if (ectx.ec_funcrefs.ga_len > 0) 2823 if (ectx.ec_funcrefs.ga_len > 0)
2817 handle_closure_in_use(&ectx, FALSE); 2824 handle_closure_in_use(&ectx, FALSE);
2818 2825
2819 estack_pop(); 2826 estack_pop();
2820 current_sctx = save_current_sctx; 2827 current_sctx = save_current_sctx;
2828
2829 if (*msg_list != NULL && saved_msg_list != NULL)
2830 {
2831 msglist_T **plist = saved_msg_list;
2832
2833 // Append entries from the current msg_list (uncaught exceptions) to
2834 // the saved msg_list.
2835 while (*plist != NULL)
2836 plist = &(*plist)->next;
2837
2838 *plist = *msg_list;
2839 }
2840 msg_list = saved_msg_list;
2821 2841
2822 failed_early: 2842 failed_early:
2823 // Free all local variables, but not arguments. 2843 // Free all local variables, but not arguments.
2824 for (idx = 0; idx < ectx.ec_stack.ga_len; ++idx) 2844 for (idx = 0; idx < ectx.ec_stack.ga_len; ++idx)
2825 clear_tv(STACK_TV(idx)); 2845 clear_tv(STACK_TV(idx));