changeset 22343:9f5a84baa464 v8.2.1720

patch 8.2.1720: Vim9: memory leak with heredoc that isn't executed Commit: https://github.com/vim/vim/commit/078269bdce7e75d5693c7313d92a229786bb95ee Author: Bram Moolenaar <Bram@vim.org> Date: Mon Sep 21 20:35:55 2020 +0200 patch 8.2.1720: Vim9: memory leak with heredoc that isn't executed Problem: Vim9: memory leak with heredoc that isn't executed. (Dominique Pell?) Solution: Don't clear the list items. (closes #6991)
author Bram Moolenaar <Bram@vim.org>
date Mon, 21 Sep 2020 20:45:04 +0200
parents 2ac192d482a3
children c5eda98d3a9b
files src/testdir/test_vim9_script.vim src/version.c src/vim9compile.c
diffstat 3 files changed, 20 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -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()
--- 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 */
 /**/
+    1720,
+/**/
     1719,
 /**/
     1718,
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -4622,15 +4622,18 @@ compile_assignment(char_u *arg, exarg_T 
 	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;