diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-07-08 15:16:19 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-07-08 15:16:19 +0200 |
commit | c620c055ce8505596a7208ba696a32b8a3be4f4b (patch) | |
tree | d61c203d6df6363f0466c4b4b8f4bd14141926c0 /src/evalvars.c | |
parent | bed36b939a4c66f41d1f24e32cfa521b10f22b82 (diff) |
patch 8.2.1154: Vim9: crash when using imported functionv8.2.1154
Problem: Vim9: crash when using imported function.
Solution: Check for a function type. Set the script context when calling a
function. (closes #6412)
Diffstat (limited to 'src/evalvars.c')
-rw-r--r-- | src/evalvars.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/evalvars.c b/src/evalvars.c index 3dab22bb2e..9cd2ec2c89 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -2375,6 +2375,7 @@ eval_variable( { int ret = OK; typval_T *tv = NULL; + int foundFunc = FALSE; dictitem_T *v; int cc; @@ -2402,21 +2403,36 @@ eval_variable( // imported variable from another script if (import != NULL) { - scriptitem_T *si = SCRIPT_ITEM(import->imp_sid); - svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) + if (import->imp_funcname != NULL) + { + foundFunc = TRUE; + if (rettv != NULL) + { + rettv->v_type = VAR_FUNC; + rettv->vval.v_string = vim_strsave(import->imp_funcname); + } + } + else + { + scriptitem_T *si = SCRIPT_ITEM(import->imp_sid); + svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) + import->imp_var_vals_idx; - tv = sv->sv_tv; + tv = sv->sv_tv; + } } } - if (tv == NULL) + if (!foundFunc) { - if (rettv != NULL && verbose) - semsg(_(e_undefvar), name); - ret = FAIL; + if (tv == NULL) + { + if (rettv != NULL && verbose) + semsg(_(e_undefvar), name); + ret = FAIL; + } + else if (rettv != NULL) + copy_tv(tv, rettv); } - else if (rettv != NULL) - copy_tv(tv, rettv); name[len] = cc; |