Skip to content

Commit

Permalink
patch 8.2.4298: divide by zero with huge tabstop value
Browse files Browse the repository at this point in the history
Problem:    Divide by zero with huge tabstop value.
Solution:   Reject tabstop value that overflows to zero.
  • Loading branch information
brammool committed Feb 5, 2022
1 parent 21ebb08 commit fc88df4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/indent.c
Expand Up @@ -71,7 +71,7 @@ tabstop_set(char_u *var, int **array)
int n = atoi((char *)cp);

// Catch negative values, overflow and ridiculous big values.
if (n < 0 || n > TABSTOP_MAX)
if (n <= 0 || n > TABSTOP_MAX)
{
semsg(_(e_invalid_argument_str), cp);
vim_free(*array);
Expand Down
10 changes: 10 additions & 0 deletions src/testdir/test_vartabs.vim
Expand Up @@ -146,6 +146,16 @@ func Test_vartabs()
bwipeout!
endfunc

func Test_retab_invalid_arg()
new
call setline(1, "\ttext")
retab 0
call assert_fails("retab -8", 'E487: Argument must be positive')
call assert_fails("retab 10000", 'E475:')
call assert_fails("retab 720575940379279360", 'E475:')
bwipe!
endfunc

func Test_vartabs_breakindent()
CheckOption breakindent
new
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -746,6 +746,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4298,
/**/
4297,
/**/
Expand Down

0 comments on commit fc88df4

Please sign in to comment.