diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-03-21 22:12:34 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-03-21 22:12:34 +0100 |
commit | 67da21a14726b106b49744f9773eba132fedd5f2 (patch) | |
tree | 64c770c5e6b831fac7a5d230516fedd3512fb9b6 /src/vim9compile.c | |
parent | 7a6eaa06f98cef61d2131c25b4b47b8262cb8f59 (diff) | |
download | vim-git-67da21a14726b106b49744f9773eba132fedd5f2.tar.gz |
patch 8.2.2636: memory leak when compiling inline functionv8.2.2636
Problem: Memory leak when compiling inline function.
Solution: Free the prefetched line.
Diffstat (limited to 'src/vim9compile.c')
-rw-r--r-- | src/vim9compile.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/vim9compile.c b/src/vim9compile.c index 09b1fce83..535de057c 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -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) |