Mercurial > vim
changeset 27667:289e87a78307 v8.2.4359
patch 8.2.4359: crash when repeatedly using :retab
Commit: https://github.com/vim/vim/commit/6e28703a8e41f775f64e442c5d11ce1ff599aa3f
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Feb 12 15:42:18 2022 +0000
patch 8.2.4359: crash when repeatedly using :retab
Problem: crash when repeatedly using :retab.
Solution: Bail out when the line is getting too long.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 12 Feb 2022 16:45:03 +0100 |
parents | c86e351c8464 |
children | 407a08328369 |
files | src/indent.c src/testdir/test_retab.vim src/version.c |
diffstat | 3 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/indent.c +++ b/src/indent.c @@ -1750,6 +1750,11 @@ ex_retab(exarg_T *eap) if (ptr[col] == NUL) break; vcol += chartabsize(ptr + col, (colnr_T)vcol); + if (vcol >= MAXCOL) + { + emsg(_(e_resulting_text_too_long)); + break; + } if (has_mbyte) col += (*mb_ptr2len)(ptr + col); else
--- a/src/testdir/test_retab.vim +++ b/src/testdir/test_retab.vim @@ -70,6 +70,8 @@ func Test_retab() call assert_equal(" a b c ", Retab('!', 3)) call assert_equal(" a b c ", Retab('', 5)) call assert_equal(" a b c ", Retab('!', 5)) + + set tabstop& expandtab& endfunc func Test_retab_error() @@ -80,4 +82,21 @@ func Test_retab_error() call assert_fails('ret 80000000000000000000', 'E475:') endfunc +func Test_retab_endless() + new + call setline(1, "\t0\t") + let caught = 'no' + try + while 1 + set ts=4000 + retab 4 + endwhile + catch /E1240/ + let caught = 'yes' + endtry + bwipe! + set tabstop& +endfunc + + " vim: shiftwidth=2 sts=2 expandtab