Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
11944:60014330374d | 11945:f37815bb7417 |
---|---|
2637 mch_settmode(TMODE_COOK); /* handle '\r' and '\n' correctly */ | 2637 mch_settmode(TMODE_COOK); /* handle '\r' and '\n' correctly */ |
2638 | 2638 |
2639 # if defined(FEAT_MBYTE) && !defined(FEAT_GUI_MSWIN) | 2639 # if defined(FEAT_MBYTE) && !defined(FEAT_GUI_MSWIN) |
2640 if (enc_codepage >= 0 && (int)GetConsoleCP() != enc_codepage) | 2640 if (enc_codepage >= 0 && (int)GetConsoleCP() != enc_codepage) |
2641 { | 2641 { |
2642 int len; | 2642 int inlen = STRLEN(str); |
2643 WCHAR *widestr = (WCHAR *)enc_to_utf16(str, &len); | 2643 int outlen; |
2644 WCHAR *widestr = (WCHAR *)enc_to_utf16(str, &inlen); | |
2644 | 2645 |
2645 if (widestr != NULL) | 2646 if (widestr != NULL) |
2646 { | 2647 { |
2647 WideCharToMultiByte_alloc(GetConsoleCP(), 0, widestr, len, | 2648 WideCharToMultiByte_alloc(GetConsoleCP(), 0, widestr, inlen, |
2648 (LPSTR *)&ccp, &len, 0, 0); | 2649 (LPSTR *)&ccp, &outlen, 0, 0); |
2649 vim_free(widestr); | 2650 vim_free(widestr); |
2650 s = str = ccp; | 2651 s = str = ccp; |
2651 } | 2652 } |
2652 } | 2653 } |
2653 # endif | 2654 # endif |