From b3d34f62dc08887fe0ce339a9e6044234f15aa15 Mon Sep 17 00:00:00 2001 From: Vic Lee Date: Wed, 19 Dec 2012 22:03:31 +0800 Subject: [PATCH] libwinpr-crt: add extra null-terminator for ConvertFromUnicode. --- winpr/libwinpr/crt/unicode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/winpr/libwinpr/crt/unicode.c b/winpr/libwinpr/crt/unicode.c index 32d9447dd..672afc123 100644 --- a/winpr/libwinpr/crt/unicode.c +++ b/winpr/libwinpr/crt/unicode.c @@ -341,7 +341,10 @@ int ConvertFromUnicode(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int allocate = TRUE; if (allocate) - *lpMultiByteStr = (LPSTR) malloc(cbMultiByte); + { + *lpMultiByteStr = (LPSTR) malloc(cbMultiByte + 1); + ZeroMemory(*lpMultiByteStr, cbMultiByte + 1); + } status = WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, *lpMultiByteStr, cbMultiByte, lpDefaultChar, lpUsedDefaultChar);