diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-04-14 12:40:00 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-04-14 12:40:00 +0200 |
commit | f62d73933af7830301989eb8162ce94a80e61fbf (patch) | |
tree | 61cd05f8b37027a585279eb0dedb43f465cb943d /src/vim9compile.c | |
parent | 2e240bd428c0033d16f201d7f837636412358199 (diff) | |
download | vim-git-f62d73933af7830301989eb8162ce94a80e61fbf.tar.gz |
patch 8.2.2762: Vim9: function line truncated when compilingv8.2.2762
Problem: Vim9: function line truncated when compiling.
Solution: Copy the line before processing it. (closes #8101)
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 4a55f1973..0ada441a4 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -8486,6 +8486,7 @@ compile_def_function( cctx_T *outer_cctx) { char_u *line = NULL; + char_u *line_to_free = NULL; char_u *p; char *errormsg = NULL; // error message cctx_T cctx; @@ -8647,6 +8648,14 @@ compile_def_function( #endif break; } + // Make a copy, splitting off nextcmd and removing trailing spaces + // may change it. + if (line != NULL) + { + line = vim_strsave(line); + vim_free(line_to_free); + line_to_free = line; + } } CLEAR_FIELD(ea); @@ -9095,6 +9104,7 @@ erret: if (do_estack_push) estack_pop(); + vim_free(line_to_free); free_imported(&cctx); free_locals(&cctx); ga_clear(&cctx.ctx_type_stack); |