patch 8.2.3241: Vim9: memory leak when function reports an error
Problem: Vim9: memory leak when function reports an error.
Solution: Clear the return value.
diff --git a/src/userfunc.c b/src/userfunc.c
index 2adef7c..045692c 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -1691,9 +1691,12 @@
ret = call_func(name, len, rettv, argcount, argvars, funcexe);
if (in_vim9script() && did_emsg > did_emsg_before)
+ {
// An error in a builtin function does not return FAIL, but we do
// want to abort further processing if an error was given.
ret = FAIL;
+ clear_tv(rettv);
+ }
funcargs.ga_len -= i;
}