mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Use dynamic buffer size in CLoggerWindowsDebugger
Make sure the Windows debugger logger does not fail when log messages are too long. The first call to `MultiByteToWideChar` gets the required size of the wide-char buffer, which should be at least one for the null termination. The second call is expected to produce exactly the same number of characters.
This commit is contained in:
parent
f74797ae0c
commit
72991fbe9a
|
@ -423,9 +423,12 @@ class CLoggerWindowsDebugger : public ILogger
|
||||||
public:
|
public:
|
||||||
void Log(const CLogMessage *pMessage) override
|
void Log(const CLogMessage *pMessage) override
|
||||||
{
|
{
|
||||||
WCHAR aWBuffer[4096];
|
int WLen = MultiByteToWideChar(CP_UTF8, 0, pMessage->m_aLine, -1, NULL, 0);
|
||||||
MultiByteToWideChar(CP_UTF8, 0, pMessage->m_aLine, -1, aWBuffer, sizeof(aWBuffer) / sizeof(WCHAR));
|
dbg_assert(WLen > 0, "MultiByteToWideChar failure");
|
||||||
OutputDebugStringW(aWBuffer);
|
WCHAR *pWide = (WCHAR *)malloc(WLen * sizeof(*pWide));
|
||||||
|
dbg_assert(MultiByteToWideChar(CP_UTF8, 0, pMessage->m_aLine, -1, pWide, WLen) == WLen, "MultiByteToWideChar failure");
|
||||||
|
OutputDebugStringW(pWide);
|
||||||
|
free(pWide);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
std::unique_ptr<ILogger> log_logger_windows_debugger()
|
std::unique_ptr<ILogger> log_logger_windows_debugger()
|
||||||
|
|
Loading…
Reference in a new issue