diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-08-15 16:08:36 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-08-15 16:08:36 +0200 |
commit | b033ee2ddfa8513b57111a56d6af9e45c41f7d1e (patch) | |
tree | e9c9f0d88d53dfb5ddfd116d9a0eb4c48a2e639b /src/evalvars.c | |
parent | a401bba0805856e295c213aa504648084dae7e24 (diff) | |
download | vim-git-b033ee2ddfa8513b57111a56d6af9e45c41f7d1e.tar.gz |
patch 8.2.3351: Vim9: using a function by name may delete itv8.2.3351
Problem: Vim9: using a function by name may delete it. (Naohiro Ono)
Solution: Increment the reference count when using a function by name.
(closes #8760)
Diffstat (limited to 'src/evalvars.c')
-rw-r--r-- | src/evalvars.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/evalvars.c b/src/evalvars.c index 2de7999a0..1af9ec562 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -2636,6 +2636,8 @@ eval_variable( { ufunc_T *ufunc = find_func(name, FALSE, NULL); + // In Vim9 script we can get a function reference by using the + // function name. if (ufunc != NULL) { found = TRUE; @@ -2643,6 +2645,8 @@ eval_variable( { rettv->v_type = VAR_FUNC; rettv->vval.v_string = vim_strsave(ufunc->uf_name); + if (rettv->vval.v_string != NULL) + func_ref(ufunc->uf_name); } } } |