Skip to content

Commit

Permalink
patch 9.0.1143: invalid memory access with bad 'statusline' value
Browse files Browse the repository at this point in the history
Problem:    Invalid memory access with bad 'statusline' value.
Solution:   Avoid going over the NUL at the end.
  • Loading branch information
brammool committed Jan 4, 2023
1 parent f057171 commit 7b17eb4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/buffer.c
Expand Up @@ -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;
}
Expand Down
7 changes: 7 additions & 0 deletions src/testdir/test_statusline.vim
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -695,6 +695,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1143,
/**/
1142,
/**/
Expand Down

0 comments on commit 7b17eb4

Please sign in to comment.