diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-09-27 14:22:48 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-09-27 14:22:48 +0200 |
commit | c0e29010f68a0ebe439f9bd78493799c60b7bfd3 (patch) | |
tree | de28c56983955b5bdbed61c7b1fe15bb666439c9 | |
parent | 8c7ad3631af570f68b2da2658cf966a9a19cb6c4 (diff) |
patch 8.2.1755: Vim9: crash when using invalid heredoc markerv8.2.1755
Problem: Vim9: crash when using invalid heredoc marker. (Dhiraj Mishra)
Solution: Check for NULL list. (closes #7027) Fix comment character.
-rw-r--r-- | src/evalvars.c | 5 | ||||
-rw-r--r-- | src/testdir/test_vim9_assign.vim | 10 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9compile.c | 2 |
4 files changed, 17 insertions, 2 deletions
diff --git a/src/evalvars.c b/src/evalvars.c index 3571169370..9aa6d6554a 100644 --- a/src/evalvars.c +++ b/src/evalvars.c @@ -558,6 +558,7 @@ heredoc_get(exarg_T *eap, char_u *cmd, int script_get) int text_indent_len = 0; char_u *text_indent = NULL; char_u dot[] = "."; + int comment_char = in_vim9script() ? '#' : '"'; if (eap->getline == NULL) { @@ -585,11 +586,11 @@ heredoc_get(exarg_T *eap, char_u *cmd, int script_get) } // The marker is the next word. - if (*cmd != NUL && *cmd != '"') + if (*cmd != NUL && *cmd != comment_char) { marker = skipwhite(cmd); p = skiptowhite(marker); - if (*skipwhite(p) != NUL && *skipwhite(p) != '"') + if (*skipwhite(p) != NUL && *skipwhite(p) != comment_char) { semsg(_(e_trailing_arg), p); return NULL; diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim index 94861e549c..0a947346a0 100644 --- a/src/testdir/test_vim9_assign.vim +++ b/src/testdir/test_vim9_assign.vim @@ -732,4 +732,14 @@ def Test_assign_lambda() CheckScriptSuccess(lines) enddef +def Test_heredoc() + var lines =<< trim END # comment + text + END + assert_equal(['text'], lines) + + CheckDefFailure(['var lines =<< trim END X', 'END'], 'E488:') + CheckDefFailure(['var lines =<< trim END " comment', 'END'], 'E488:') +enddef + " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker diff --git a/src/version.c b/src/version.c index 1ee6801c9e..2072b35290 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1755, +/**/ 1754, /**/ 1753, diff --git a/src/vim9compile.c b/src/vim9compile.c index 2d640155fd..832d7d93e1 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -4632,6 +4632,8 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx) eap->getline = exarg_getline; eap->cookie = cctx; l = heredoc_get(eap, op + 3, FALSE); + if (l == NULL) + return NULL; if (cctx->ctx_skip != SKIP_YES) { |