]> granicus.if.org Git - vim/commitdiff
patch 9.0.1143: invalid memory access with bad 'statusline' value v9.0.1143
authorBram Moolenaar <Bram@vim.org>
Wed, 4 Jan 2023 14:31:49 +0000 (14:31 +0000)
committerBram Moolenaar <Bram@vim.org>
Wed, 4 Jan 2023 14:31:49 +0000 (14:31 +0000)
Problem:    Invalid memory access with bad 'statusline' value.
Solution:   Avoid going over the NUL at the end.

src/buffer.c
src/testdir/test_statusline.vim
src/version.c

index 98568987894eae587a9c90aafee78505464afa60..40168226160cd2f1aa5ae3f7b012b910c22c6530 100644 (file)
@@ -4617,6 +4617,8 @@ build_stl_str_hl(
 #endif
        if (vim_strchr(STL_ALL, *s) == NULL)
        {
+           if (*s == NUL)  // can happen with "%0"
+               break;
            s++;
            continue;
        }
index a829597655bf7092291687fd1857fd023f7b1383..23613bfed37b9813642fb970b603e7758eaf4f0b 100644 (file)
@@ -440,6 +440,13 @@ func Test_statusline()
   set splitbelow&
 endfunc
 
+func Test_statusline_trailing_percent_zero()
+  " this was causing illegal memory access
+  set laststatus=2 stl=%!%0
+  call assert_fails('redraw', 'E15: Invalid expression: "%0"')
+  set laststatus& stl&
+endfunc
+
 func Test_statusline_visual()
   func CallWordcount()
     call wordcount()
index df02bb87b87dbd2ff06b2a993b296668a854d131..4ccbd537abe30329eda5164e273ec843ec01bc2d 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1143,
 /**/
     1142,
 /**/