vim-patch:8.2.5097: using uninitialized memory when using 'listchars' (#18985)

Problem:    Using uninitialized memory when using 'listchars'.
Solution:   Use the length returned by mb_char2bytes(). (closes vim/vim#10576)
74ac29cecd
This commit is contained in:
zeertzjq
2022-06-16 19:09:59 +08:00
committed by GitHub
parent 5243cb8a4b
commit 351b5969c1

View File

@@ -1812,8 +1812,8 @@ void msg_prt_line(char_u *s, int list)
} else if (curwin->w_p_lcs_chars.nbsp != NUL && list
&& (utf_ptr2char(s) == 160
|| utf_ptr2char(s) == 0x202f)) {
utf_char2bytes(curwin->w_p_lcs_chars.nbsp, (char_u *)buf);
buf[utfc_ptr2len((char_u *)buf)] = NUL;
int len = utf_char2bytes(curwin->w_p_lcs_chars.nbsp, (char_u *)buf);
buf[len] = NUL;
} else {
memmove(buf, s, (size_t)l);
buf[l] = NUL;