forked from aniani/vim
patch 8.2.1332: Vim9: memory leak when using nested global function
Problem: Vim9: memory leak when using nested global function. Solution: Delete the function when deleting the instruction. Disable test that still causes a leak.
This commit is contained in:
@@ -7677,8 +7677,21 @@ delete_instr(isn_T *isn)
|
||||
break;
|
||||
|
||||
case ISN_NEWFUNC:
|
||||
vim_free(isn->isn_arg.newfunc.nf_lambda);
|
||||
vim_free(isn->isn_arg.newfunc.nf_global);
|
||||
{
|
||||
char_u *lambda = isn->isn_arg.newfunc.nf_lambda;
|
||||
ufunc_T *ufunc = find_func_even_dead(lambda, TRUE, NULL);
|
||||
|
||||
if (ufunc != NULL)
|
||||
{
|
||||
// Clear uf_dfunc_idx so that the function is deleted.
|
||||
clear_def_function(ufunc);
|
||||
ufunc->uf_dfunc_idx = 0;
|
||||
func_ptr_unref(ufunc);
|
||||
}
|
||||
|
||||
vim_free(lambda);
|
||||
vim_free(isn->isn_arg.newfunc.nf_global);
|
||||
}
|
||||
break;
|
||||
|
||||
case ISN_2BOOL:
|
||||
|
Reference in New Issue
Block a user