]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.3391: crash with combination of 'linebreak' and other options v8.2.3391
authorBram Moolenaar <Bram@vim.org>
Tue, 31 Aug 2021 18:57:55 +0000 (20:57 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 31 Aug 2021 18:57:55 +0000 (20:57 +0200)
Problem:    Crash with combination of 'linebreak' and other options.
Solution:   Avoid n_extra to become negative. (Christian Brabandt,
            closes #8817)

src/drawline.c
src/version.c

index deeaf5f168c0e86de8a1f69d7de27dbde6acd354..98d76930f36199704cde6656eabd760988bbe9cb 100644 (file)
@@ -1970,17 +1970,22 @@ win_line(
                if (wp->w_p_lbr && c0 == c
                                  && VIM_ISBREAK(c) && !VIM_ISBREAK((int)*ptr))
                {
-                   int mb_off = has_mbyte ? (*mb_head_off)(line, ptr - 1) : 0;
-                   char_u *p = ptr - (mb_off + 1);
+                   int     mb_off = has_mbyte ? (*mb_head_off)(line, ptr - 1)
+                                                                          : 0;
+                   char_u  *p = ptr - (mb_off + 1);
 
                    // TODO: is passing p for start of the line OK?
                    n_extra = win_lbr_chartabsize(wp, line, p, (colnr_T)vcol,
                                                                    NULL) - 1;
 
                    // We have just drawn the showbreak value, no need to add
-                   // space for it again
+                   // space for it again.
                    if (vcol == vcol_sbr)
+                   {
                        n_extra -= MB_CHARLEN(get_showbreak_value(wp));
+                       if (n_extra < 0)
+                           n_extra = 0;
+                   }
 
                    if (c == TAB && n_extra + col > wp->w_width)
 # ifdef FEAT_VARTABS
index ce649e0eea0ebe0d3fa1030d68dd42af21d587c6..b574d5d461b6487443f72b8d9a0edf49bc5b8957 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3391,
 /**/
     3390,
 /**/