]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0730: Crash with cursor-screenline and narrow window v9.1.0730
authorzeertzjq <zeertzjq@outlook.com>
Sat, 14 Sep 2024 08:40:29 +0000 (10:40 +0200)
committerChristian Brabandt <cb@256bit.org>
Sat, 14 Sep 2024 08:40:29 +0000 (10:40 +0200)
Problem:  Crash with cursor-screenline and narrow window
          (elig0n)
Solution: Don't set right_col when width2 is 0 (zeertzjq).

fixes: #15677
closes: #15678

Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/drawline.c
src/testdir/test_cursorline.vim
src/version.c

index b627192a4ee0f94d31bdf5d2d52f0f52900e25aa..fd5d56b43e50889400d813c24b271055c23e0c10 100644 (file)
@@ -62,7 +62,7 @@ margin_columns_win(win_T *wp, int *left_col, int *right_col)
     *left_col = 0;
     *right_col = width1;
 
-    if (wp->w_virtcol >= (colnr_T)width1)
+    if (wp->w_virtcol >= (colnr_T)width1 && width2 > 0)
        *right_col = width1 + ((wp->w_virtcol - width1) / width2 + 1) * width2;
     if (wp->w_virtcol >= (colnr_T)width1 && width2 > 0)
        *left_col = (wp->w_virtcol - width1) / width2 * width2 + width1;
index bdde670d207a545cefb284f4993605a22a21bbee..d258111ae4de11a46366f5269dc97736049d41e3 100644 (file)
@@ -309,6 +309,17 @@ func Test_cursorline_screenline_update()
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_cursorline_screenline_zero_width()
+  CheckOption foldcolumn
+
+  set cursorline culopt=screenline winminwidth=1 foldcolumn=1
+  " This used to crash Vim
+  1vnew | redraw
+
+  bwipe!
+  set cursorline& culopt& winminwidth& foldcolumn&
+endfunc
+
 func Test_cursorline_cursorbind_horizontal_scroll()
   CheckScreendump
 
index c1ee2d5751b07975247c6363446f30ca18ebe114..4f6375bd3bb95fcaa05f83bdf6802ea588f1c548 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    730,
 /**/
     729,
 /**/