1
0
forked from aniani/vim

patch 8.2.2636: memory leak when compiling inline function

Problem:    Memory leak when compiling inline function.
Solution:   Free the prefetched line.
This commit is contained in:
Bram Moolenaar
2021-03-21 22:12:34 +01:00
parent 7a6eaa06f9
commit 67da21a147
6 changed files with 26 additions and 9 deletions

View File

@@ -3202,6 +3202,16 @@ compile_lambda(char_u **arg, cctx_T *cctx)
// 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)