diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-08-03 18:55:00 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-08-03 18:55:00 +0200 |
commit | 1b66c00aeca87913e75012c59c4e969316e2626d (patch) | |
tree | ef86e077b2810640997623aeff1d9d863937a0d2 /src/message.c | |
parent | 69a76feda9e9d308be6b5fc2185286a061dfecd6 (diff) | |
download | vim-1b66c00aeca87913e75012c59c4e969316e2626d.zip |
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)
Diffstat (limited to 'src/message.c')
-rw-r--r-- | src/message.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/message.c b/src/message.c index 9a4a32f3e..e548fc0c9 100644 --- a/src/message.c +++ b/src/message.c @@ -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; } |