0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.0.0852: MS-Windows: possible crash when giving a message on startup

Problem:    MS-Windows: possible crash when giving a message on startup.
Solution:   Initialize length. (Yasuhiro Matsumoto, closes #1931)
This commit is contained in:
Bram Moolenaar
2017-08-03 18:55:00 +02:00
parent 69a76feda9
commit 1b66c00aec
2 changed files with 7 additions and 4 deletions

View File

@@ -2639,13 +2639,14 @@ msg_puts_printf(char_u *str, int maxlen)
# if defined(FEAT_MBYTE) && !defined(FEAT_GUI_MSWIN)
if (enc_codepage >= 0 && (int)GetConsoleCP() != enc_codepage)
{
int len;
WCHAR *widestr = (WCHAR *)enc_to_utf16(str, &len);
int inlen = STRLEN(str);
int outlen;
WCHAR *widestr = (WCHAR *)enc_to_utf16(str, &inlen);
if (widestr != NULL)
{
WideCharToMultiByte_alloc(GetConsoleCP(), 0, widestr, len,
(LPSTR *)&ccp, &len, 0, 0);
WideCharToMultiByte_alloc(GetConsoleCP(), 0, widestr, inlen,
(LPSTR *)&ccp, &outlen, 0, 0);
vim_free(widestr);
s = str = ccp;
}