diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-08-17 22:14:29 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-08-17 22:14:29 +0200 |
commit | 02f8694a6bd116ab3316add4a7ea6735bf2e8839 (patch) | |
tree | 78008d785172ad8fdc40e399401f823839f5f8d6 | |
parent | ccfb7c6758510e0fe5f390149ea14aee6ff4f55e (diff) | |
download | vim-git-02f8694a6bd116ab3316add4a7ea6735bf2e8839.tar.gz |
patch 8.2.3357: crash when 'virtualedit' is set and window is narrowv8.2.3357
Problem: Crash when 'virtualedit' is set and window is narrow. ()
Solution: Check that width is not zero. (closes #8767)
-rw-r--r-- | src/misc2.c | 3 | ||||
-rw-r--r-- | src/testdir/test_number.vim | 11 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 15 insertions, 1 deletions
diff --git a/src/misc2.c b/src/misc2.c index 271014f7a..2436f9fb0 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -161,7 +161,8 @@ coladvance2( if (finetune && curwin->w_p_wrap && curwin->w_width != 0 - && wcol >= (colnr_T)width) + && wcol >= (colnr_T)width + && width > 0) { csize = linetabsize(line); if (csize > 0) diff --git a/src/testdir/test_number.vim b/src/testdir/test_number.vim index 13f8de719..78cd6f901 100644 --- a/src/testdir/test_number.vim +++ b/src/testdir/test_number.vim @@ -320,4 +320,15 @@ func Test_number_rightleft() bw! endfunc +" This used to cause a divide by zero +func Test_number_no_text_virtual_edit() + vnew + call setline(1, ['line one', 'line two']) + set number virtualedit=all + normal w + 4wincmd | + normal j + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 97a58e3c0..727257d28 100644 --- a/src/version.c +++ b/src/version.c @@ -756,6 +756,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3357, +/**/ 3356, /**/ 3355, |