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

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 07:18:27 +08:00
committed by GitHub
parent 0c6ad03c3f
commit 4cc05a75ea

View File

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