• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revision9f5a84baa4645b4ec9be2d923b09202203770618 (tree)
Zeit2020-09-22 03:45:04
AutorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

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)

Ändern Zusammenfassung

Diff

diff -r 2ac192d482a3 -r 9f5a84baa464 src/testdir/test_vim9_script.vim
--- a/src/testdir/test_vim9_script.vim Sun Sep 20 22:45:04 2020 +0200
+++ b/src/testdir/test_vim9_script.vim Mon Sep 21 20:45:04 2020 +0200
@@ -259,6 +259,14 @@
259259 let w: number
260260 w = 123
261261 assert_equal(123, w)
262+
263+
264+ # this should not leak
265+ if 0
266+ let text =<< trim END
267+ some text
268+ END
269+ endif
262270 enddef
263271
264272 def Test_vim9_single_char_vars()
diff -r 2ac192d482a3 -r 9f5a84baa464 src/version.c
--- a/src/version.c Sun Sep 20 22:45:04 2020 +0200
+++ b/src/version.c Mon Sep 21 20:45:04 2020 +0200
@@ -751,6 +751,8 @@
751751 static int included_patches[] =
752752 { /* Add new patch number below this line */
753753 /**/
754+ 1720,
755+/**/
754756 1719,
755757 /**/
756758 1718,
diff -r 2ac192d482a3 -r 9f5a84baa464 src/vim9compile.c
--- a/src/vim9compile.c Sun Sep 20 22:45:04 2020 +0200
+++ b/src/vim9compile.c Mon Sep 21 20:45:04 2020 +0200
@@ -4622,15 +4622,18 @@
46224622 eap->cookie = cctx;
46234623 l = heredoc_get(eap, op + 3, FALSE);
46244624
4625- // Push each line and the create the list.
4626- FOR_ALL_LIST_ITEMS(l, li)
4625+ if (cctx->ctx_skip != SKIP_YES)
46274626 {
4628- generate_PUSHS(cctx, li->li_tv.vval.v_string);
4629- li->li_tv.vval.v_string = NULL;
4627+ // Push each line and the create the list.
4628+ FOR_ALL_LIST_ITEMS(l, li)
4629+ {
4630+ generate_PUSHS(cctx, li->li_tv.vval.v_string);
4631+ li->li_tv.vval.v_string = NULL;
4632+ }
4633+ generate_NEWLIST(cctx, l->lv_len);
4634+ type = &t_list_string;
4635+ member_type = &t_list_string;
46304636 }
4631- generate_NEWLIST(cctx, l->lv_len);
4632- type = &t_list_string;
4633- member_type = &t_list_string;
46344637 list_free(l);
46354638 p += STRLEN(p);
46364639 end = p;
Show on old repository browser