To: vim_dev@googlegroups.com Subject: Patch 8.2.1259 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1259 Problem: Empty group in 'tabline' may cause using an invalid pointer. Solution: Set the group start position. (closes #6505) Files: src/buffer.c, src/testdir/test_tabline.vim *** ../vim-8.2.1258/src/buffer.c 2020-06-24 20:33:59.561106332 +0200 --- src/buffer.c 2020-07-21 19:23:30.698928399 +0200 *************** *** 4229,4240 **** } if (n == curitem && group_start_userhl == group_end_userhl) { p = t; l = 0; - // do not use the highlighting from the removed group for (n = groupitem[groupdepth] + 1; n < curitem; n++) if (item[n].type == Highlight) item[n].type = Empty; } } if (l > item[groupitem[groupdepth]].maxwid) --- 4229,4247 ---- } if (n == curitem && group_start_userhl == group_end_userhl) { + // empty group p = t; l = 0; for (n = groupitem[groupdepth] + 1; n < curitem; n++) + { + // do not use the highlighting from the removed group if (item[n].type == Highlight) item[n].type = Empty; + // adjust the start position of TabPage to the next + // item position + if (item[n].type == TabPage) + item[n].start = p; + } } } if (l > item[groupitem[groupdepth]].maxwid) *** ../vim-8.2.1258/src/testdir/test_tabline.vim 2020-06-25 19:01:32.989844093 +0200 --- src/testdir/test_tabline.vim 2020-07-21 19:22:31.115147211 +0200 *************** *** 112,115 **** --- 112,138 ---- %bw! 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 *** ../vim-8.2.1258/src/version.c 2020-07-20 23:10:52.993054034 +0200 --- src/version.c 2020-07-21 19:20:12.175677378 +0200 *************** *** 756,757 **** --- 756,759 ---- { /* Add new patch number below this line */ + /**/ + 1259, /**/ -- hundred-and-one symptoms of being an internet addict: 53. To find out what time it is, you send yourself an e-mail and check the "Date:" field. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///