]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.2126: unused assignments when checking 'listchars' v9.0.2126
authorzeertzjq <zeertzjq@outlook.com>
Thu, 23 Nov 2023 19:47:16 +0000 (20:47 +0100)
committerChristian Brabandt <cb@256bit.org>
Thu, 23 Nov 2023 19:47:16 +0000 (20:47 +0100)
Problem:  Unused assignments when checking the value of 'listchars'.
Solution: Loop only once when just checking the value.  Add a test to
          check that this change doesn't cause double-free.

closes: #13559

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/screen.c
src/testdir/test_listchars.vim
src/version.c

index fd69cf0b3dd354e0121089eb1f3d638dcab6645e..ac24a164648cd49fd08f43827c0e4805b127b6dd 100644 (file)
@@ -4726,7 +4726,7 @@ set_chars_option(win_T *wp, char_u *value, int is_listchars, int apply)
     }
 
     // first round: check for valid value, second round: assign values
-    for (round = 0; round <= 1; ++round)
+    for (round = 0; round <= (apply ? 1 : 0); ++round)
     {
        if (round > 0)
        {
@@ -4913,11 +4913,6 @@ set_chars_option(win_T *wp, char_u *value, int is_listchars, int apply)
            wp->w_fill_chars = fill_chars;
        }
     }
-    else if (is_listchars)
-    {
-       vim_free(lcs_chars.multispace);
-       vim_free(lcs_chars.leadmultispace);
-    }
 
     return NULL;       // no error
 }
index 8628fb20e04abfaf0bedd69f742617c73f972fae..57ddcda7e51f1b1cea3a089d8dcc6f418dd51a3a 100644 (file)
@@ -265,6 +265,11 @@ func Test_listchars()
   call Check_listchars(expected, 5, 12)
   call assert_equal(expected, split(execute("%list"), "\n"))
 
+  " Changing the value of 'ambiwidth' twice shouldn't cause double-free when
+  " "leadmultispace" is specified.
+  set ambiwidth=double
+  set ambiwidth&
+
   " Test leadmultispace and lead and space
   normal ggdG
   set listchars&
index 801ca36d13e42624c4fcdd7c6dcdabe226578d96..8e35aaa09d86516cec2563f7095c90e22de66061 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2126,
 /**/
     2125,
 /**/