Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
25629:afbcd19a3e2c | 25630:c26eb08a0df2 |
---|---|
2634 } | 2634 } |
2635 else if (in_vim9script()) | 2635 else if (in_vim9script()) |
2636 { | 2636 { |
2637 ufunc_T *ufunc = find_func(name, FALSE, NULL); | 2637 ufunc_T *ufunc = find_func(name, FALSE, NULL); |
2638 | 2638 |
2639 // In Vim9 script we can get a function reference by using the | |
2640 // function name. | |
2639 if (ufunc != NULL) | 2641 if (ufunc != NULL) |
2640 { | 2642 { |
2641 found = TRUE; | 2643 found = TRUE; |
2642 if (rettv != NULL) | 2644 if (rettv != NULL) |
2643 { | 2645 { |
2644 rettv->v_type = VAR_FUNC; | 2646 rettv->v_type = VAR_FUNC; |
2645 rettv->vval.v_string = vim_strsave(ufunc->uf_name); | 2647 rettv->vval.v_string = vim_strsave(ufunc->uf_name); |
2648 if (rettv->vval.v_string != NULL) | |
2649 func_ref(ufunc->uf_name); | |
2646 } | 2650 } |
2647 } | 2651 } |
2648 } | 2652 } |
2649 } | 2653 } |
2650 | 2654 |