mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 13:15:09 -07:00
vim-patch:8.2.1259: empty group in 'tabline' may cause using an invalid pointer
Problem: Empty group in 'tabline' may cause using an invalid pointer. Solution: Set the group start position. (closes vim/vim#6505)f56c95fdad
(cherry picked from commit9443d39941
)
This commit is contained in:
parent
fd02e63513
commit
23c99bb78f
@ -3530,13 +3530,19 @@ int build_stl_str_hl(
|
||||
}
|
||||
}
|
||||
if (n == curitem && group_start_userhl == group_end_userhl) {
|
||||
// empty group
|
||||
out_p = t;
|
||||
group_len = 0;
|
||||
// do not use the highlighting from the removed group
|
||||
for (n = groupitems[groupdepth] + 1; n < curitem; n++) {
|
||||
// do not use the highlighting from the removed group
|
||||
if (items[n].type == Highlight) {
|
||||
items[n].type = Empty;
|
||||
}
|
||||
// adjust the start position of TabPage to the next
|
||||
// item position
|
||||
if (items[n].type == TabPage) {
|
||||
items[n].start = out_p;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,3 +64,28 @@ func Test_redrawtabline()
|
||||
let &showtabline = showtabline_save
|
||||
au! Bufadd
|
||||
endfunc
|
||||
|
||||
function EmptyTabname()
|
||||
return ""
|
||||
endfunction
|
||||
|
||||
function MakeTabLine() abort
|
||||
let titles = map(range(1, tabpagenr('$')), '"%( %" . v:val . "T%{EmptyTabname()}%T %)"')
|
||||
let sep = 'あ'
|
||||
let tabpages = join(titles, sep)
|
||||
return tabpages .. sep .. '%=%999X X'
|
||||
endfunction
|
||||
|
||||
func Test_tabline_empty_group()
|
||||
" this was reading invalid memory
|
||||
set tabline=%!MakeTabLine()
|
||||
tabnew
|
||||
redraw!
|
||||
|
||||
tabclose
|
||||
set tabline=
|
||||
endfunc
|
||||
|
||||
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
Loading…
Reference in New Issue
Block a user