Mercurial > vim
diff src/userfunc.c @ 22326:fb69b43d73f3 v8.2.1712
patch 8.2.1712: Vim9: leaking memory when calling a lambda
Commit: https://github.com/vim/vim/commit/a05e524f3aa8eadc2dbd0ad8ff6db9407ac7ac7e
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Sep 19 18:19:19 2020 +0200
patch 8.2.1712: Vim9: leaking memory when calling a lambda
Problem: Vim9: leaking memory when calling a lambda.
Solution: Decrement function reference from ISN_DCALL.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 19 Sep 2020 18:30:04 +0200 |
parents | a4ed0de125d9 |
children | 56f674e7518c |
line wrap: on
line diff
--- a/src/userfunc.c +++ b/src/userfunc.c @@ -1058,7 +1058,7 @@ cleanup_function_call(funccall_T *fc) * using function() does not count as a reference, because the function is * looked up by name. */ - static int + int func_name_refcount(char_u *name) { return isdigit(*name) || *name == '<'; @@ -1176,8 +1176,9 @@ func_clear(ufunc_T *fp, int force) * Free a function and remove it from the list of functions. Does not free * what a function contains, call func_clear() first. * When "force" is TRUE we are exiting. + * Returns OK when the function was actually freed. */ - static void + static int func_free(ufunc_T *fp, int force) { // Only remove it when not done already, otherwise we would remove a newer @@ -1191,7 +1192,9 @@ func_free(ufunc_T *fp, int force) unlink_def_function(fp); VIM_CLEAR(fp->uf_name_exp); vim_free(fp); + return OK; } + return FAIL; } /* @@ -1890,9 +1893,13 @@ free_all_functions(void) ++skipped; else { - func_free(fp, FALSE); - skipped = 0; - break; + if (func_free(fp, FALSE) == OK) + { + skipped = 0; + break; + } + // did not actually free it + ++skipped; } } }