Skip to content

Commit ac18dff

Browse files
patch 9.2.0273: tabpanel: undefined behaviour with large tabpanelop columns
Problem: tabpanel: undefined behaviour with large tabpanelop columns (Michał Majchrowicz) Solution: Error out for too large column values Co-authored-by: Michał Majchrowicz <mmajchrowicz@afine.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent e4502b6 commit ac18dff

3 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/tabpanel.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ tabpanelopt_changed(void)
5757
{
5858
char_u *p;
5959
int new_align = ALIGN_LEFT;
60-
int new_columns = 20;
60+
long new_columns = 20;
6161
int new_is_vert = FALSE;
6262

6363
p = p_tplo;
@@ -83,6 +83,8 @@ tabpanelopt_changed(void)
8383
{
8484
p += 8;
8585
new_columns = getdigits(&p);
86+
if (new_columns < 1 || new_columns > 1000)
87+
return FAIL;
8688
}
8789
else if (STRNCMP(p, "vert", 4) == 0)
8890
{

src/testdir/test_tabpanel.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,4 +887,9 @@ func Test_tabpanel_no_modeline()
887887
bw!
888888
endfunc
889889

890+
func Test_tabpanel_large_columns()
891+
call assert_fails(':set tabpanelopt=columns:10001', 'E474:')
892+
call assert_fails(':set tabpanelopt=columns:-1', 'E474:')
893+
endfunc
894+
890895
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ static char *(features[]) =
734734

735735
static int included_patches[] =
736736
{ /* Add new patch number below this line */
737+
/**/
738+
273,
737739
/**/
738740
272,
739741
/**/

0 commit comments

Comments
 (0)