libwinpr-crt: add extra null-terminator for ConvertFromUnicode.

This commit is contained in:
Vic Lee 2012-12-19 22:03:31 +08:00
parent ecd9136ca8
commit b3d34f62dc

View File

@ -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);