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/userfunc.c | |
parent | 7a6eaa06f98cef61d2131c25b4b47b8262cb8f59 (diff) |
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/userfunc.c')
-rw-r--r-- | src/userfunc.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/userfunc.c b/src/userfunc.c index 51894dc101..a53c4769c7 100644 --- a/src/userfunc.c +++ b/src/userfunc.c @@ -970,17 +970,18 @@ lambda_function_body( ga_init2(&newlines, (int)sizeof(char_u *), 10); if (get_function_body(&eap, &newlines, NULL, &line_to_free) == FAIL) + { + vim_free(cmdline); goto erret; + } if (cmdline != NULL) { // Something comes after the "}". *arg = eap.nextcmd; - if (evalarg->eval_cctx == NULL) - { - // Need to keep the line and free it/ later. - vim_free(evalarg->eval_tofree_lambda); - evalarg->eval_tofree_lambda = cmdline; - } + + // "arg" points into cmdline, need to keep the line and free it later. + vim_free(evalarg->eval_tofree_cmdline); + evalarg->eval_tofree_cmdline = cmdline; } else *arg = (char_u *)""; |