{
stl_items = ALLOC_MULT(stl_item_T, stl_items_len);
stl_groupitem = ALLOC_MULT(int, stl_items_len);
- stl_hltab = ALLOC_MULT(stl_hlrec_T, stl_items_len);
- stl_tabtab = ALLOC_MULT(stl_hlrec_T, stl_items_len);
+
+ // Allocate one more, because the last element is used to indicate the
+ // end of the list.
+ stl_hltab = ALLOC_MULT(stl_hlrec_T, stl_items_len + 1);
+ stl_tabtab = ALLOC_MULT(stl_hlrec_T, stl_items_len + 1);
}
#ifdef FEAT_EVAL
if (new_groupitem == NULL)
break;
stl_groupitem = new_groupitem;
- new_hlrec = vim_realloc(stl_hltab, sizeof(stl_hlrec_T) * new_len);
+ new_hlrec = vim_realloc(stl_hltab,
+ sizeof(stl_hlrec_T) * (new_len + 1));
if (new_hlrec == NULL)
break;
stl_hltab = new_hlrec;
- new_hlrec = vim_realloc(stl_tabtab, sizeof(stl_hlrec_T) * new_len);
+ new_hlrec = vim_realloc(stl_tabtab,
+ sizeof(stl_hlrec_T) * (new_len + 1));
if (new_hlrec == NULL)
break;
stl_tabtab = new_hlrec;
set tabline=
endfunc
+" When there are exactly 20 tabline format items (the exact size of the
+" initial tabline items array), test that we don't write beyond the size
+" of the array.
+func Test_tabline_20_format_items_no_overrun()
+ set showtabline=2
+ let tabline = repeat('%#StatColorHi2#', 20)
+ let &tabline = tabline
+ redrawtabline
+
+ set showtabline& tabline&
+endfunc
" vim: shiftwidth=2 sts=2 expandtab