1
0
forked from aniani/vim

patch 9.0.1527: crash when using negative value for term_cols

Problem:    Crash when using negative value for term_cols.
Solution:   Check for invalid term_cols value. (Kenta Sato, closes #12362)
This commit is contained in:
Kenta Sato 2023-05-08 18:26:03 +01:00 committed by Bram Moolenaar
parent d619d6a9c6
commit c28e7a2b2f
3 changed files with 18 additions and 2 deletions

View File

@ -272,7 +272,8 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
*lp = tv_get_number(item);
if (*lp < 0)
{
semsg(_(e_invalid_value_for_argument_str_str), hi->hi_key, tv_get_string(item));
semsg(_(e_invalid_value_for_argument_str_str),
hi->hi_key, tv_get_string(item));
return FAIL;
}
}
@ -444,10 +445,19 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
}
else if (STRCMP(hi->hi_key, "term_cols") == 0)
{
int error = FALSE;
if (!(supported2 & JO2_TERM_COLS))
break;
opt->jo_set2 |= JO2_TERM_COLS;
opt->jo_term_cols = tv_get_number(item);
opt->jo_term_cols = tv_get_number_chk(item, &error);
if (error)
return FAIL;
if (opt->jo_term_cols < 0 || opt->jo_term_cols > 1000)
{
semsg(_(e_invalid_value_for_argument_str), "term_cols");
return FAIL;
}
}
else if (STRCMP(hi->hi_key, "vertical") == 0)
{

View File

@ -617,6 +617,10 @@ func Test_terminal_size()
call assert_fails("call term_start(cmd, {'term_rows': 1001})", 'E475:')
call assert_fails("call term_start(cmd, {'term_rows': 10.0})", 'E805:')
call assert_fails("call term_start(cmd, {'term_cols': -1})", 'E475:')
call assert_fails("call term_start(cmd, {'term_cols': 1001})", 'E475:')
call assert_fails("call term_start(cmd, {'term_cols': 10.0})", 'E805:')
call delete('Xtext')
endfunc

View File

@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1527,
/**/
1526,
/**/