Mercurial > vim
comparison src/message.c @ 29155:4d72bdf70625 v8.2.5097
patch 8.2.5097: using uninitialized memory when using 'listchars'
Commit: https://github.com/vim/vim/commit/74ac29cecd56457ee93f3f71b31b7a2e6d9712d6
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jun 15 12:12:44 2022 +0100
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 https://github.com/vim/vim/issues/10576)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 15 Jun 2022 13:15:03 +0200 |
parents | d8a962d7b008 |
children | d9acbf59032c |
comparison
equal
deleted
inserted
replaced
29154:e01302a9d6c8 | 29155:4d72bdf70625 |
---|---|
1918 } | 1918 } |
1919 else if (curwin->w_lcs_chars.nbsp != NUL && list | 1919 else if (curwin->w_lcs_chars.nbsp != NUL && list |
1920 && (mb_ptr2char(s) == 160 | 1920 && (mb_ptr2char(s) == 160 |
1921 || mb_ptr2char(s) == 0x202f)) | 1921 || mb_ptr2char(s) == 0x202f)) |
1922 { | 1922 { |
1923 mb_char2bytes(curwin->w_lcs_chars.nbsp, buf); | 1923 int len = mb_char2bytes(curwin->w_lcs_chars.nbsp, buf); |
1924 buf[(*mb_ptr2len)(buf)] = NUL; | 1924 |
1925 buf[len] = NUL; | |
1925 } | 1926 } |
1926 else | 1927 else |
1927 { | 1928 { |
1928 mch_memmove(buf, s, (size_t)l); | 1929 mch_memmove(buf, s, (size_t)l); |
1929 buf[l] = NUL; | 1930 buf[l] = NUL; |