summaryrefslogtreecommitdiff
path: root/src/vim9compile.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-04-14 12:40:00 +0200
committerBram Moolenaar <Bram@vim.org>2021-04-14 12:40:00 +0200
commitf62d73933af7830301989eb8162ce94a80e61fbf (patch)
tree61cd05f8b37027a585279eb0dedb43f465cb943d /src/vim9compile.c
parent2e240bd428c0033d16f201d7f837636412358199 (diff)
downloadvim-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.c10
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);