# HG changeset patch # User Bram Moolenaar # Date 1644059704 -3600 # Node ID 8e8fb566dfa5bf5e13f236b2164a288069258c95 # Parent 20a4152753edf333e8f834887f4e781868aa0336 patch 8.2.4298: divide by zero with huge tabstop value Commit: https://github.com/vim/vim/commit/fc88df42f1ae64bcc4d6cbc0fbd3445f8c59afdf Author: Bram Moolenaar Date: Sat Feb 5 11:13:05 2022 +0000 patch 8.2.4298: divide by zero with huge tabstop value Problem: Divide by zero with huge tabstop value. Solution: Reject tabstop value that overflows to zero. diff --git a/src/indent.c b/src/indent.c --- a/src/indent.c +++ b/src/indent.c @@ -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); diff --git a/src/testdir/test_vartabs.vim b/src/testdir/test_vartabs.vim --- a/src/testdir/test_vartabs.vim +++ b/src/testdir/test_vartabs.vim @@ -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 diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4298, +/**/ 4297, /**/ 4296,