Skip to content

Commit 1b66c00

Browse files
committed
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)
1 parent 69a76fe commit 1b66c00

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/message.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2639,13 +2639,14 @@ msg_puts_printf(char_u *str, int maxlen)
26392639
# if defined(FEAT_MBYTE) && !defined(FEAT_GUI_MSWIN)
26402640
if (enc_codepage >= 0 && (int)GetConsoleCP() != enc_codepage)
26412641
{
2642-
int len;
2643-
WCHAR *widestr = (WCHAR *)enc_to_utf16(str, &len);
2642+
int inlen = STRLEN(str);
2643+
int outlen;
2644+
WCHAR *widestr = (WCHAR *)enc_to_utf16(str, &inlen);
26442645

26452646
if (widestr != NULL)
26462647
{
2647-
WideCharToMultiByte_alloc(GetConsoleCP(), 0, widestr, len,
2648-
(LPSTR *)&ccp, &len, 0, 0);
2648+
WideCharToMultiByte_alloc(GetConsoleCP(), 0, widestr, inlen,
2649+
(LPSTR *)&ccp, &outlen, 0, 0);
26492650
vim_free(widestr);
26502651
s = str = ccp;
26512652
}

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static char *(features[]) =
769769

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
852,
772774
/**/
773775
851,
774776
/**/

0 commit comments

Comments
 (0)