comparison src/drawline.c @ 31315:6a03cc83fcc5 v9.0.0991

patch 9.0.0991: crash when reading help index with various options set Commit: https://github.com/vim/vim/commit/c67c89c7589253215d57bad588edcf83a9403560 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Dec 2 16:39:44 2022 +0000 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)
author Bram Moolenaar <Bram@vim.org>
date Fri, 02 Dec 2022 17:45:03 +0100
parents d7a532c4d18d
children a93392e93a53
comparison
equal deleted inserted replaced
31314:e8dca3baf3c7 31315:6a03cc83fcc5
2892 // when getting a character from the file, we may have to 2892 // when getting a character from the file, we may have to
2893 // turn it into something else on the way to putting it 2893 // turn it into something else on the way to putting it
2894 // into "ScreenLines". 2894 // into "ScreenLines".
2895 if (c == TAB && (!wp->w_p_list || wp->w_lcs_chars.tab1)) 2895 if (c == TAB && (!wp->w_p_list || wp->w_lcs_chars.tab1))
2896 { 2896 {
2897 int tab_len = 0; 2897 int tab_len = 0;
2898 long vcol_adjusted = wlv.vcol; // removed showbreak length 2898 long vcol_adjusted = wlv.vcol; // removed showbreak len
2899 #ifdef FEAT_LINEBREAK 2899 #ifdef FEAT_LINEBREAK
2900 char_u *sbr = get_showbreak_value(wp); 2900 char_u *sbr = get_showbreak_value(wp);
2901 2901
2902 // only adjust the tab_len, when at the first column 2902 // only adjust the tab_len, when at the first column
2903 // after the showbreak value was drawn 2903 // after the showbreak value was drawn
2904 if (*sbr != NUL && wlv.vcol == wlv.vcol_sbr && wp->w_p_wrap) 2904 if (*sbr != NUL && wlv.vcol == wlv.vcol_sbr && wp->w_p_wrap)
2905 vcol_adjusted = wlv.vcol - MB_CHARLEN(sbr); 2905 vcol_adjusted = wlv.vcol - MB_CHARLEN(sbr);
2915 #endif 2915 #endif
2916 2916
2917 #ifdef FEAT_LINEBREAK 2917 #ifdef FEAT_LINEBREAK
2918 if (!wp->w_p_lbr || !wp->w_p_list) 2918 if (!wp->w_p_lbr || !wp->w_p_list)
2919 #endif 2919 #endif
2920 {
2920 // tab amount depends on current column 2921 // tab amount depends on current column
2921 wlv.n_extra = tab_len; 2922 wlv.n_extra = tab_len;
2923 }
2922 #ifdef FEAT_LINEBREAK 2924 #ifdef FEAT_LINEBREAK
2923 else 2925 else
2924 { 2926 {
2925 char_u *p; 2927 char_u *p;
2926 int len; 2928 int len;
2938 && wlv.n_extra > tab_len) 2940 && wlv.n_extra > tab_len)
2939 tab_len += wlv.n_extra - tab_len; 2941 tab_len += wlv.n_extra - tab_len;
2940 # endif 2942 # endif
2941 if (tab_len > 0) 2943 if (tab_len > 0)
2942 { 2944 {
2943 // If wlv.n_extra > 0, it gives the number of 2945 // If wlv.n_extra > 0, it gives the number of chars
2944 // chars, to use for a tab, else we need to 2946 // to use for a tab, else we need to calculate the
2945 // calculate the width for a tab. 2947 // width for a tab.
2946 int tab2_len = mb_char2len(wp->w_lcs_chars.tab2); 2948 int tab2_len = mb_char2len(wp->w_lcs_chars.tab2);
2947 len = tab_len * tab2_len; 2949 len = tab_len * tab2_len;
2948 if (wp->w_lcs_chars.tab3) 2950 if (wp->w_lcs_chars.tab3)
2949 len += mb_char2len(wp->w_lcs_chars.tab3) 2951 len += mb_char2len(wp->w_lcs_chars.tab3)
2950 - tab2_len; 2952 - tab2_len;
3016 { 3018 {
3017 c = (wlv.n_extra == 0 && wp->w_lcs_chars.tab3) 3019 c = (wlv.n_extra == 0 && wp->w_lcs_chars.tab3)
3018 ? wp->w_lcs_chars.tab3 3020 ? wp->w_lcs_chars.tab3
3019 : wp->w_lcs_chars.tab1; 3021 : wp->w_lcs_chars.tab1;
3020 #ifdef FEAT_LINEBREAK 3022 #ifdef FEAT_LINEBREAK
3021 if (wp->w_p_lbr) 3023 if (wp->w_p_lbr && wlv.p_extra != NULL)
3022 wlv.c_extra = NUL; // using p_extra from above 3024 wlv.c_extra = NUL; // using p_extra from above
3023 else 3025 else
3024 #endif 3026 #endif
3025 wlv.c_extra = wp->w_lcs_chars.tab2; 3027 wlv.c_extra = wp->w_lcs_chars.tab2;
3026 wlv.c_final = wp->w_lcs_chars.tab3; 3028 wlv.c_final = wp->w_lcs_chars.tab3;