Mercurial > vim
changeset 22413:66d1131a7eff v8.2.1755
patch 8.2.1755: Vim9: crash when using invalid heredoc marker
Commit: https://github.com/vim/vim/commit/c0e29010f68a0ebe439f9bd78493799c60b7bfd3
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Sep 27 14:22:48 2020 +0200
patch 8.2.1755: Vim9: crash when using invalid heredoc marker
Problem: Vim9: crash when using invalid heredoc marker. (Dhiraj Mishra)
Solution: Check for NULL list. (closes https://github.com/vim/vim/issues/7027) Fix comment character.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 27 Sep 2020 14:30:04 +0200 |
parents | fad0df9b45e0 |
children | f22c7b159f37 |
files | src/evalvars.c src/testdir/test_vim9_assign.vim src/version.c src/vim9compile.c |
diffstat | 4 files changed, 17 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/evalvars.c +++ b/src/evalvars.c @@ -558,6 +558,7 @@ heredoc_get(exarg_T *eap, char_u *cmd, i 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, i } // 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;
--- 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