patch 8.2.2636: memory leak when compiling inline function
Problem: Memory leak when compiling inline function.
Solution: Free the prefetched line.
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 09b1fce..535de05 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -3202,6 +3202,16 @@
// Compile the function into instructions.
compile_def_function(ufunc, TRUE, PROFILING(ufunc), cctx);
+ // evalarg.eval_tofree_cmdline may have a copy of the last line and "*arg"
+ // points into it. Point to the original line to avoid a dangling pointer.
+ if (evalarg.eval_tofree_cmdline != NULL)
+ {
+ size_t off = *arg - evalarg.eval_tofree_cmdline;
+
+ *arg = ((char_u **)cctx->ctx_ufunc->uf_lines.ga_data)[cctx->ctx_lnum]
+ + off;
+ }
+
clear_evalarg(&evalarg, NULL);
if (ufunc->uf_def_status == UF_COMPILED)