0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.2.1711: Vim9: leaking memory when using partial

Problem:    Vim9: leaking memory when using partial.
Solution:   Do delete the function even when it was compiled.
This commit is contained in:
Bram Moolenaar
2020-09-19 15:16:50 +02:00
parent 77b20977dc
commit fdeab65db6
5 changed files with 45 additions and 17 deletions

View File

@@ -2593,6 +2593,9 @@ compile_lambda(char_u **arg, cctx_T *cctx)
// The return type will now be known.
set_function_type(ufunc);
// The function reference count will be 1. When the ISN_FUNCREF
// instruction is deleted the reference count is decremented and the
// function is freed.
return generate_FUNCREF(cctx, ufunc);
}
@@ -7424,6 +7427,18 @@ clear_def_function(ufunc_T *ufunc)
}
}
/*
* Used when a user function is about to be deleted: remove the pointer to it.
* The entry in def_functions is then unused.
*/
void
unlink_def_function(ufunc_T *ufunc)
{
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data) + ufunc->uf_dfunc_idx;
dfunc->df_ufunc = NULL;
}
#if defined(EXITFREE) || defined(PROTO)
/*
* Free all functions defined with ":def".