From 4cc05a75ea9e67099e8a54311390af299c4f462e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 16 Jun 2022 07:18:27 +0800 Subject: 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) https://github.com/vim/vim/commit/74ac29cecd56457ee93f3f71b31b7a2e6d9712d6 --- src/nvim/message.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/message.c b/src/nvim/message.c index 182f8494a1..4ae11ee135 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1851,8 +1851,8 @@ void msg_prt_line(char_u *s, int list) } else if (curwin->w_p_lcs_chars.nbsp != NUL && list && (utf_ptr2char((char *)s) == 160 || utf_ptr2char((char *)s) == 0x202f)) { - utf_char2bytes(curwin->w_p_lcs_chars.nbsp, buf); - buf[utfc_ptr2len(buf)] = NUL; + int len = utf_char2bytes(curwin->w_p_lcs_chars.nbsp, buf); + buf[len] = NUL; } else { memmove(buf, s, (size_t)l); buf[l] = NUL; -- cgit