changeset 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 60014330374d
children 2e9cf6f47b11
files src/message.c src/version.c
diffstat 2 files changed, 7 insertions(+), 4 deletions(-) [+]
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;
 	}
--- a/src/version.c
+++ b/src/version.c
@@ -770,6 +770,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    852,
+/**/
     851,
 /**/
     850,