diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-04-15 21:54:04 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-15 21:54:04 -0400 |
commit | d8e7fbe193cb3c811e305873a1f99b9f02d36d5f (patch) | |
tree | 1c28ab9cb3df836e149a92ca878548b1b4758f1e /src/nvim/eval/userfunc.c | |
parent | b8c0fac762f4b03f0438d3888ccf3f200648b882 (diff) | |
parent | 97288e73c27d45b0fadbd6efa437fe54bc58b5e3 (diff) | |
download | rneovim-d8e7fbe193cb3c811e305873a1f99b9f02d36d5f.tar.gz rneovim-d8e7fbe193cb3c811e305873a1f99b9f02d36d5f.tar.bz2 rneovim-d8e7fbe193cb3c811e305873a1f99b9f02d36d5f.zip |
Merge pull request #14367 from janlazo/vim-8.2.2046
vim-patch:8.2.{265,2761,2764}
Diffstat (limited to 'src/nvim/eval/userfunc.c')
-rw-r--r-- | src/nvim/eval/userfunc.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c index 689d05e079..00260bc3f7 100644 --- a/src/nvim/eval/userfunc.c +++ b/src/nvim/eval/userfunc.c @@ -833,6 +833,8 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, bool islambda = false; char_u numbuf[NUMBUFLEN]; char_u *name; + typval_T *tv_to_free[MAX_FUNC_ARGS]; + int tv_to_free_len = 0; proftime_T wait_start; proftime_T call_start; int started_profiling = false; @@ -985,6 +987,11 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, v->di_tv = isdefault ? def_rettv : argvars[i]; v->di_tv.v_lock = VAR_FIXED; + if (isdefault) { + // Need to free this later, no matter where it's stored. + tv_to_free[tv_to_free_len++] = &v->di_tv; + } + if (addlocal) { // Named arguments can be accessed without the "a:" prefix in lambda // expressions. Add to the l: dict. @@ -1209,7 +1216,9 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, did_emsg |= save_did_emsg; depth--; - + for (int i = 0; i < tv_to_free_len; i++) { + tv_clear(tv_to_free[i]); + } cleanup_function_call(fc); if (--fp->uf_calls <= 0 && fp->uf_refcount <= 0) { |