]> granicus.if.org Git - vim/commitdiff
patch 8.2.3357: crash when 'virtualedit' is set and window is narrow v8.2.3357
authorBram Moolenaar <Bram@vim.org>
Tue, 17 Aug 2021 20:14:29 +0000 (22:14 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 17 Aug 2021 20:14:29 +0000 (22:14 +0200)
Problem:    Crash when 'virtualedit' is set and window is narrow. ()
Solution:   Check that width is not zero. (closes #8767)

src/misc2.c
src/testdir/test_number.vim
src/version.c

index 271014f7a3fec1521c4d7f1f1a281ae3bce8181f..2436f9fb06d454aaf46230d102cc8ca6942b3145 100644 (file)
@@ -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)
index 13f8de719d893c68bdb6892eec87e84bbfc9d600..78cd6f9012e419f670ed26829ba96f2d76cb213b 100644 (file)
@@ -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
index 97a58e3c0219260a328998e5fc4000b865b17fa8..727257d28d491d66853fdd7a348241259d435fad 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3357,
 /**/
     3356,
 /**/