]> granicus.if.org Git - vim/commitdiff
patch 8.2.1720: Vim9: memory leak with heredoc that isn't executed v8.2.1720
authorBram Moolenaar <Bram@vim.org>
Mon, 21 Sep 2020 18:35:55 +0000 (20:35 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 21 Sep 2020 18:35:55 +0000 (20:35 +0200)
Problem:    Vim9: memory leak with heredoc that isn't executed. (Dominique
            PellĂ©)
Solution:   Don't clear the list items. (closes #6991)

src/testdir/test_vim9_script.vim
src/version.c
src/vim9compile.c

index 42eaab0ada9bfbda3429c2eb4be99c5d12074758..c00df6be243fda4e906646acdc5964013e6ac82e 100644 (file)
@@ -259,6 +259,14 @@ def Test_assignment()
   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()
index 15c497671a45536e9459c33e6709e8d04cad821b..a5cb6a8815af3126a587cfdeb7c06759001530e1 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1720,
 /**/
     1719,
 /**/
index 1edf48ce6e3a7f751d1c9f12d9c00d84d0c05eaf..52651f36a1a898fef075e1ec1695c8c452f9fc72 100644 (file)
@@ -4622,15 +4622,18 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
        eap->cookie = cctx;
        l = heredoc_get(eap, op + 3, FALSE);
 
-       // Push each line and the create the list.
-       FOR_ALL_LIST_ITEMS(l, li)
+       if (cctx->ctx_skip != SKIP_YES)
        {
-           generate_PUSHS(cctx, li->li_tv.vval.v_string);
-           li->li_tv.vval.v_string = NULL;
+           // 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;
        }
-       generate_NEWLIST(cctx, l->lv_len);
-       type = &t_list_string;
-       member_type = &t_list_string;
        list_free(l);
        p += STRLEN(p);
        end = p;