diff src/message.c @ 11945:f37815bb7417 v8.0.0852

patch 8.0.0852: MS-Windows: possible crash when giving a message on startup commit https://github.com/vim/vim/commit/1b66c00aeca87913e75012c59c4e969316e2626d Author: Bram Moolenaar <Bram@vim.org> Date: Thu Aug 3 18:55:00 2017 +0200 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 https://github.com/vim/vim/issues/1931)
author Christian Brabandt <cb@256bit.org>
date Thu, 03 Aug 2017 19:00:05 +0200
parents 351d94dc8375
children 7e704d75a882
line wrap: on
line diff
--- 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;
 	}