mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.1154: Vim9: crash when using imported function
Problem: Vim9: crash when using imported function. Solution: Check for a function type. Set the script context when calling a function. (closes #6412)
This commit is contained in:
@@ -160,6 +160,7 @@ call_dfunc(int cdf_idx, int argcount_arg, ectx_T *ectx)
|
||||
int arg_to_add;
|
||||
int vararg_count = 0;
|
||||
int idx;
|
||||
estack_T *entry;
|
||||
|
||||
if (dfunc->df_deleted)
|
||||
{
|
||||
@@ -230,7 +231,14 @@ call_dfunc(int cdf_idx, int argcount_arg, ectx_T *ectx)
|
||||
// Set execution state to the start of the called function.
|
||||
ectx->ec_dfunc_idx = cdf_idx;
|
||||
ectx->ec_instr = dfunc->df_instr;
|
||||
estack_push_ufunc(dfunc->df_ufunc, 1);
|
||||
entry = estack_push_ufunc(dfunc->df_ufunc, 1);
|
||||
if (entry != NULL)
|
||||
{
|
||||
// Set the script context to the script where the function was defined.
|
||||
// TODO: save more than the SID?
|
||||
entry->es_save_sid = current_sctx.sc_sid;
|
||||
current_sctx.sc_sid = ufunc->uf_script_ctx.sc_sid;
|
||||
}
|
||||
|
||||
// Decide where to start execution, handles optional arguments.
|
||||
init_instr_idx(ufunc, argcount, ectx);
|
||||
@@ -386,9 +394,12 @@ func_return(ectx_T *ectx)
|
||||
+ ectx->ec_dfunc_idx;
|
||||
int argcount = ufunc_argcount(dfunc->df_ufunc);
|
||||
int top = ectx->ec_frame_idx - argcount;
|
||||
estack_T *entry;
|
||||
|
||||
// execution context goes one level up
|
||||
estack_pop();
|
||||
entry = estack_pop();
|
||||
if (entry != NULL)
|
||||
current_sctx.sc_sid = entry->es_save_sid;
|
||||
|
||||
if (handle_closure_in_use(ectx, TRUE) == FAIL)
|
||||
return FAIL;
|
||||
|
Reference in New Issue
Block a user