Fix low-level WindowsPlatform::Log to not print invalid characters

This commit is contained in:
Wojtek Figat
2021-02-10 23:13:16 +01:00
parent 4c673bec9b
commit 8158c94d26

View File

@@ -630,8 +630,19 @@ void WindowsPlatform::Exit()
void WindowsPlatform::Log(const StringView& msg)
{
OutputDebugStringW(msg.Get());
OutputDebugStringW(TEXT(PLATFORM_LINE_TERMINATOR));
Char buffer[500];
Char* str;
if (msg.Length() + 3 < ARRAY_COUNT(buffer))
str = buffer;
else
str = new Char[msg.Length() + 3];
MemoryCopy(str, msg.Get(), msg.Length() * sizeof(Char));
str[msg.Length() + 0] = '\r';
str[msg.Length() + 1] = '\n';
str[msg.Length() + 2] = 0;
OutputDebugStringW(str);
if (str != buffer)
Free(str);
}
bool WindowsPlatform::IsDebuggerPresent()