1
0
forked from aniani/vim

patch 9.0.0991: crash when reading help index with various options set

Problem:    Crash when reading help index with various options set. (Marius
            Gedminas)
Solution:   Do not set wlv.c_extra to NUL when wlv.p_extra is NULL.
            (closes #11651)
This commit is contained in:
Bram Moolenaar
2022-12-02 16:39:44 +00:00
parent c96b7f5d2a
commit c67c89c758
3 changed files with 29 additions and 7 deletions

View File

@@ -2895,7 +2895,7 @@ win_line(
if (c == TAB && (!wp->w_p_list || wp->w_lcs_chars.tab1)) if (c == TAB && (!wp->w_p_list || wp->w_lcs_chars.tab1))
{ {
int tab_len = 0; int tab_len = 0;
long vcol_adjusted = wlv.vcol; // removed showbreak length long vcol_adjusted = wlv.vcol; // removed showbreak len
#ifdef FEAT_LINEBREAK #ifdef FEAT_LINEBREAK
char_u *sbr = get_showbreak_value(wp); char_u *sbr = get_showbreak_value(wp);
@@ -2917,8 +2917,10 @@ win_line(
#ifdef FEAT_LINEBREAK #ifdef FEAT_LINEBREAK
if (!wp->w_p_lbr || !wp->w_p_list) if (!wp->w_p_lbr || !wp->w_p_list)
#endif #endif
{
// tab amount depends on current column // tab amount depends on current column
wlv.n_extra = tab_len; wlv.n_extra = tab_len;
}
#ifdef FEAT_LINEBREAK #ifdef FEAT_LINEBREAK
else else
{ {
@@ -2940,9 +2942,9 @@ win_line(
# endif # endif
if (tab_len > 0) if (tab_len > 0)
{ {
// If wlv.n_extra > 0, it gives the number of // If wlv.n_extra > 0, it gives the number of chars
// chars, to use for a tab, else we need to // to use for a tab, else we need to calculate the
// calculate the width for a tab. // width for a tab.
int tab2_len = mb_char2len(wp->w_lcs_chars.tab2); int tab2_len = mb_char2len(wp->w_lcs_chars.tab2);
len = tab_len * tab2_len; len = tab_len * tab2_len;
if (wp->w_lcs_chars.tab3) if (wp->w_lcs_chars.tab3)
@@ -3018,7 +3020,7 @@ win_line(
? wp->w_lcs_chars.tab3 ? wp->w_lcs_chars.tab3
: wp->w_lcs_chars.tab1; : wp->w_lcs_chars.tab1;
#ifdef FEAT_LINEBREAK #ifdef FEAT_LINEBREAK
if (wp->w_p_lbr) if (wp->w_p_lbr && wlv.p_extra != NULL)
wlv.c_extra = NUL; // using p_extra from above wlv.c_extra = NUL; // using p_extra from above
else else
#endif #endif

View File

@@ -1034,4 +1034,22 @@ func Test_breakindent_column()
bwipeout! bwipeout!
endfunc endfunc
func Test_linebreak_list()
" This was setting wlv.c_extra to NUL while wlv.p_extra is NULL
filetype plugin on
syntax enable
edit! $VIMRUNTIME/doc/index.txt
/v_P
setlocal list
setlocal listchars=tab:>-
setlocal linebreak
setlocal nowrap
setlocal filetype=help
redraw!
bwipe!
endfunc
" vim: shiftwidth=2 sts=2 expandtab " vim: shiftwidth=2 sts=2 expandtab

View File

@@ -695,6 +695,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
991,
/**/ /**/
990, 990,
/**/ /**/