1
0
forked from aniani/vim

patch 8.2.3753: Vim9: function unreferenced while called is never deleted

Problem:    Vim9: function unreferenced while called is never deleted.
Solution:   Delete a function when no longer referenced.
This commit is contained in:
Bram Moolenaar
2021-12-06 15:06:54 +00:00
parent 8603be338a
commit 2336c376d5
4 changed files with 7 additions and 3 deletions

View File

@@ -4988,8 +4988,9 @@ call_def_function(
estack_pop();
current_sctx = save_current_sctx;
// TODO: when is it safe to delete the function if it is no longer used?
--ufunc->uf_calls;
if (--ufunc->uf_calls <= 0 && ufunc->uf_refcount <= 0)
// Function was unreferenced while being used, free it now.
func_clear_free(ufunc, FALSE);
if (*msg_list != NULL && saved_msg_list != NULL)
{