Mercurial > vim
diff src/evalvars.c @ 25630:c26eb08a0df2 v8.2.3351
patch 8.2.3351: Vim9: using a function by name may delete it
Commit: https://github.com/vim/vim/commit/b033ee2ddfa8513b57111a56d6af9e45c41f7d1e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Aug 15 16:08:36 2021 +0200
patch 8.2.3351: Vim9: using a function by name may delete it
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 15 Aug 2021 16:15:03 +0200 |
parents | 15b54e0a576b |
children | fc8046209eaa |
line wrap: on
line diff
--- 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); } } }