Patch 8.2.1755
Problem:    Vim9: crash when using invalid heredoc marker. (Dhiraj Mishra)
Solution:   Check for NULL list. (closes #7027)  Fix comment character.
Files:      src/vim9compile.c, src/evalvars.c,
            src/testdir/test_vim9_assign.vim


*** ../vim-8.2.1754/src/vim9compile.c   2020-09-26 15:08:52.881779910 +0200
--- src/vim9compile.c   2020-09-27 14:13:27.680093778 +0200
***************
*** 4632,4637 ****
--- 4632,4639 ----
        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)
        {
*** ../vim-8.2.1754/src/evalvars.c      2020-09-27 13:51:09.099888719 +0200
--- src/evalvars.c      2020-09-27 14:19:07.043260860 +0200
***************
*** 558,563 ****
--- 558,564 ----
      int               text_indent_len = 0;
      char_u    *text_indent = NULL;
      char_u    dot[] = ".";
+     int               comment_char = in_vim9script() ? '#' : '"';
  
      if (eap->getline == NULL)
      {
***************
*** 585,595 ****
      }
  
      // The marker is the next word.
!     if (*cmd != NUL && *cmd != '"')
      {
        marker = skipwhite(cmd);
        p = skiptowhite(marker);
!       if (*skipwhite(p) != NUL && *skipwhite(p) != '"')
        {
            semsg(_(e_trailing_arg), p);
            return NULL;
--- 586,596 ----
      }
  
      // The marker is the next word.
!     if (*cmd != NUL && *cmd != comment_char)
      {
        marker = skipwhite(cmd);
        p = skiptowhite(marker);
!       if (*skipwhite(p) != NUL && *skipwhite(p) != comment_char)
        {
            semsg(_(e_trailing_arg), p);
            return NULL;
*** ../vim-8.2.1754/src/testdir/test_vim9_assign.vim    2020-09-26 
15:08:52.885779899 +0200
--- src/testdir/test_vim9_assign.vim    2020-09-27 14:20:00.907122096 +0200
***************
*** 732,735 ****
--- 732,745 ----
    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
*** ../vim-8.2.1754/src/version.c       2020-09-27 13:58:33.346697763 +0200
--- src/version.c       2020-09-27 14:14:34.243926225 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     1755,
  /**/

-- 
You have heard the saying that if you put a thousand monkeys in a room with a
thousand typewriters and waited long enough, eventually you would have a room
full of dead monkeys.
                                (Scott Adams - The Dilbert principle)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202009271223.08RCNvfQ143163%40masaka.moolenaar.net.

Raspunde prin e-mail lui