Skip to content

Commit 20e0c3d

Browse files
committed
patch 8.2.3391: crash with combination of 'linebreak' and other options
Problem: Crash with combination of 'linebreak' and other options. Solution: Avoid n_extra to become negative. (Christian Brabandt, closes #8817)
1 parent ba02e47 commit 20e0c3d

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/drawline.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,17 +1970,22 @@ win_line(
19701970
if (wp->w_p_lbr && c0 == c
19711971
&& VIM_ISBREAK(c) && !VIM_ISBREAK((int)*ptr))
19721972
{
1973-
int mb_off = has_mbyte ? (*mb_head_off)(line, ptr - 1) : 0;
1974-
char_u *p = ptr - (mb_off + 1);
1973+
int mb_off = has_mbyte ? (*mb_head_off)(line, ptr - 1)
1974+
: 0;
1975+
char_u *p = ptr - (mb_off + 1);
19751976

19761977
// TODO: is passing p for start of the line OK?
19771978
n_extra = win_lbr_chartabsize(wp, line, p, (colnr_T)vcol,
19781979
NULL) - 1;
19791980

19801981
// We have just drawn the showbreak value, no need to add
1981-
// space for it again
1982+
// space for it again.
19821983
if (vcol == vcol_sbr)
1984+
{
19831985
n_extra -= MB_CHARLEN(get_showbreak_value(wp));
1986+
if (n_extra < 0)
1987+
n_extra = 0;
1988+
}
19841989

19851990
if (c == TAB && n_extra + col > wp->w_width)
19861991
# ifdef FEAT_VARTABS

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,8 @@ static char *(features[]) =
755755

756756
static int included_patches[] =
757757
{ /* Add new patch number below this line */
758+
/**/
759+
3391,
758760
/**/
759761
3390,
760762
/**/

0 commit comments

Comments
 (0)