From: Bram Moolenaar Date: Wed, 15 Jun 2022 11:12:44 +0000 (+0100) Subject: patch 8.2.5097: using uninitialized memory when using 'listchars' X-Git-Tag: v8.2.5097 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=74ac29cecd56457ee93f3f71b31b7a2e6d9712d6;p=vim 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 3c9e4a011..07566da94 100644 --- a/src/message.c +++ b/src/message.c @@ -1920,8 +1920,9 @@ msg_prt_line(char_u *s, int list) && (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 { diff --git a/src/version.c b/src/version.c index 3ee54db42..4d63c8656 100644 --- a/src/version.c +++ b/src/version.c @@ -734,6 +734,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 5097, /**/ 5096, /**/