Patch 8.2.1720
Problem:    Vim9: memory leak with heredoc that isn't executed. (Dominique
            Pellé)
Solution:   Don't clear the list items. (closes #6991)
Files:      src/vim9compile.c, src/testdir/test_vim9_script.vim


*** ../vim-8.2.1719/src/vim9compile.c   2020-09-20 22:43:48.205496879 +0200
--- src/vim9compile.c   2020-09-21 20:34:17.139626834 +0200
***************
*** 4622,4636 ****
        eap->cookie = cctx;
        l = heredoc_get(eap, op + 3, FALSE);
  
!       // Push each line and the create the list.
!       FOR_ALL_LIST_ITEMS(l, li)
        {
!           generate_PUSHS(cctx, li->li_tv.vval.v_string);
!           li->li_tv.vval.v_string = NULL;
        }
-       generate_NEWLIST(cctx, l->lv_len);
-       type = &t_list_string;
-       member_type = &t_list_string;
        list_free(l);
        p += STRLEN(p);
        end = p;
--- 4622,4639 ----
        eap->cookie = cctx;
        l = heredoc_get(eap, op + 3, FALSE);
  
!       if (cctx->ctx_skip != SKIP_YES)
        {
!           // Push each line and the create the list.
!           FOR_ALL_LIST_ITEMS(l, li)
!           {
!               generate_PUSHS(cctx, li->li_tv.vval.v_string);
!               li->li_tv.vval.v_string = NULL;
!           }
!           generate_NEWLIST(cctx, l->lv_len);
!           type = &t_list_string;
!           member_type = &t_list_string;
        }
        list_free(l);
        p += STRLEN(p);
        end = p;
*** ../vim-8.2.1719/src/testdir/test_vim9_script.vim    2020-09-17 
21:28:59.943951831 +0200
--- src/testdir/test_vim9_script.vim    2020-09-21 20:32:21.376167668 +0200
***************
*** 259,264 ****
--- 259,272 ----
    let w: number
    w = 123
    assert_equal(123, w)
+ 
+ 
+   # this should not leak
+   if 0
+     let text =<< trim END
+       some text
+     END
+   endif
  enddef
  
  def Test_vim9_single_char_vars()
*** ../vim-8.2.1719/src/version.c       2020-09-20 22:43:48.209496857 +0200
--- src/version.c       2020-09-21 20:35:23.811315902 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     1720,
  /**/

-- 
DENNIS: You can't expect to wield supreme executive power just 'cause some
        watery tart threw a sword at you!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// 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/202009211836.08LIaSGt3462724%40masaka.moolenaar.net.

Raspunde prin e-mail lui