Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/coreclr/pal/tests/palsuite/common/palsuite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,19 @@ CRITICAL_SECTION CriticalSection;

WCHAR* convert(const char * aString)
{
int size;
WCHAR* wideBuffer;
WCHAR* wideBuffer = nullptr;

size = MultiByteToWideChar(CP_ACP,0,aString,-1,NULL,0);
wideBuffer = (WCHAR*) malloc(size*sizeof(WCHAR));
if (wideBuffer == NULL)
if (aString != nullptr)
{
Fail("ERROR: Unable to allocate memory!\n");
int size = MultiByteToWideChar(CP_ACP,0,aString,-1,NULL,0);
wideBuffer = (WCHAR*) malloc(size*sizeof(WCHAR));
if (wideBuffer == NULL)
{
Fail("ERROR: Unable to allocate memory!\n");
}
MultiByteToWideChar(CP_ACP,0,aString,-1,wideBuffer,size);
}
MultiByteToWideChar(CP_ACP,0,aString,-1,wideBuffer,size);

return wideBuffer;
}

Expand Down