patch 8.2.5097: using uninitialized memory when using 'listchars'
Problem: Using uninitialized memory when using 'listchars'.
Solution: Use the length returned by mb_char2bytes(). (closes #10576)
diff --git a/src/message.c b/src/message.c
index 3c9e4a0..07566da 100644
--- a/src/message.c
+++ b/src/message.c
@@ -1920,8 +1920,9 @@
&& (mb_ptr2char(s) == 160
|| mb_ptr2char(s) == 0x202f))
{
- mb_char2bytes(curwin->w_lcs_chars.nbsp, buf);
- buf[(*mb_ptr2len)(buf)] = NUL;
+ int len = mb_char2bytes(curwin->w_lcs_chars.nbsp, buf);
+
+ buf[len] = NUL;
}
else
{