summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2021-11-02 20:56:07 +0000
committerBram Moolenaar <Bram@vim.org>2021-11-02 20:56:07 +0000
commit7a33ebfc5b04353aa7674972087d581def8fdcc1 (patch)
treefe623937ebf748c44a587ad53c0ca9dcc825b67f
parente2f66064d1c643f0cf12c4791de04bb123705a0c (diff)
downloadvim-git-7a33ebfc5b04353aa7674972087d581def8fdcc1.tar.gz
patch 8.2.3572: memory leak when closing window and using "multispace"v8.2.3572
Problem: Memory leak when closing window and using "multispace" in 'listchars'. Solution: Free the memory. (closes #9071)
-rw-r--r--src/testdir/test_listchars.vim16
-rw-r--r--src/version.c2
-rw-r--r--src/window.c2
3 files changed, 15 insertions, 5 deletions
diff --git a/src/testdir/test_listchars.vim b/src/testdir/test_listchars.vim
index cb947aa84..9cf215213 100644
--- a/src/testdir/test_listchars.vim
+++ b/src/testdir/test_listchars.vim
@@ -445,7 +445,7 @@ func Test_listchars_window_local()
call assert_equal(['{......}--one==two##$'], ScreenLines(1, virtcol('$')))
" Setting the global setting to the default value should not impact a window
- " using a local setting
+ " using a local setting.
split
setlocal listchars=tab:<->,lead:_,space:.,trail:@,eol:#
setglobal listchars&vim
@@ -454,7 +454,7 @@ func Test_listchars_window_local()
call assert_equal(['^I one two $'], ScreenLines(1, virtcol('$')))
" Setting the local setting to the default value should not impact a window
- " using a global setting
+ " using a global setting.
set listchars=tab:{.},lead:-,space:=,trail:#,eol:$
split
setlocal listchars=tab:<->,lead:_,space:.,trail:@,eol:#
@@ -465,7 +465,7 @@ func Test_listchars_window_local()
call assert_equal(['{......}--one==two##$'], ScreenLines(1, virtcol('$')))
" Using set in a window with a local setting should change it to use the
- " global setting and also impact other windows using the global setting
+ " global setting and also impact other windows using the global setting.
split
setlocal listchars=tab:<->,lead:_,space:.,trail:@,eol:#
call assert_equal(['<------>__one..two@@#'], ScreenLines(1, virtcol('$')))
@@ -475,7 +475,7 @@ func Test_listchars_window_local()
call assert_equal(['+------+^^one>>two<<%'], ScreenLines(1, virtcol('$')))
" Setting invalid value for a local setting should not impact the local and
- " global settings
+ " global settings.
split
setlocal listchars=tab:<->,lead:_,space:.,trail:@,eol:#
let cmd = 'setlocal listchars=tab:{.},lead:-,space:=,trail:#,eol:$,x'
@@ -485,7 +485,7 @@ func Test_listchars_window_local()
call assert_equal(['+------+^^one>>two<<%'], ScreenLines(1, virtcol('$')))
" Setting invalid value for a global setting should not impact the local and
- " global settings
+ " global settings.
split
setlocal listchars=tab:<->,lead:_,space:.,trail:@,eol:#
let cmd = 'setglobal listchars=tab:{.},lead:-,space:=,trail:#,eol:$,x'
@@ -494,6 +494,12 @@ func Test_listchars_window_local()
close
call assert_equal(['+------+^^one>>two<<%'], ScreenLines(1, virtcol('$')))
+ " Closing window with local lcs-multispace should not cause a memory leak.
+ setlocal listchars=multispace:---+
+ split
+ call s:CheckListCharsValue('multispace:---+')
+ close
+
%bw!
set list& listchars&
endfunc
diff --git a/src/version.c b/src/version.c
index 43e861545..b7f64c76e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3572,
+/**/
3571,
/**/
3570,
diff --git a/src/window.c b/src/window.c
index b0bdd5946..5de6ed7f5 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5041,6 +5041,8 @@ win_free(
clear_winopt(&wp->w_onebuf_opt);
clear_winopt(&wp->w_allbuf_opt);
+ vim_free(wp->w_lcs_chars.multispace);
+
#ifdef FEAT_EVAL
vars_clear(&wp->w_vars->dv_hashtab); // free all w: variables
hash_init(&wp->w_vars->dv_hashtab);