patch 8.2.2762: Vim9: function line truncated when compiling
Problem: Vim9: function line truncated when compiling.
Solution: Copy the line before processing it. (closes #8101)
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 4a55f19..0ada441 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -8486,6 +8486,7 @@
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 @@
#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 @@
if (do_estack_push)
estack_pop();
+ vim_free(line_to_free);
free_imported(&cctx);
free_locals(&cctx);
ga_clear(&cctx.ctx_type_stack);