Mercurial > vim
diff src/vim9compile.c @ 22324:a4ed0de125d9 v8.2.1711
patch 8.2.1711: Vim9: leaking memory when using partial
Commit: https://github.com/vim/vim/commit/fdeab65db60929e28640fd740c333f9bcfea0e15
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Sep 19 15:16:50 2020 +0200
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 19 Sep 2020 15:30:04 +0200 |
parents | 3f5f96a8dd83 |
children | fb69b43d73f3 |
line wrap: on
line diff
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -2593,6 +2593,9 @@ compile_lambda(char_u **arg, cctx_T *cct // 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".