Silence valgrind in unicode conversion functions

Only check destination buffer for NULL if length argument did not
already indicate the buffer needs to be allocated.
This commit is contained in:
akallabeth 2020-05-07 15:38:35 +02:00
parent 94e38f7285
commit bc0a2c277d

View File

@ -403,13 +403,12 @@ int ConvertToUnicode(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cb
cchWideChar = MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, NULL, 0);
allocate = TRUE;
}
else if (!(*lpWideCharStr))
allocate = TRUE;
if (cchWideChar < 1)
return 0;
if (!(*lpWideCharStr))
allocate = TRUE;
if (allocate)
{
*lpWideCharStr = (LPWSTR)calloc(cchWideChar + 1, sizeof(WCHAR));
@ -473,13 +472,12 @@ int ConvertFromUnicode(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int
WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, NULL, 0, NULL, NULL);
allocate = TRUE;
}
else if (!(*lpMultiByteStr))
allocate = TRUE;
if (cbMultiByte < 1)
return 0;
if (!(*lpMultiByteStr))
allocate = TRUE;
if (allocate)
{
*lpMultiByteStr = (LPSTR)calloc(1, cbMultiByte + 1);