Common/Log: Fix corrupted output/UB with va_copy

Fixes crashes on GCC9+ (#9), maybe others.
This commit is contained in:
Connor McLaughlin 2020-02-01 11:04:29 +10:00
parent c72d86cf1b
commit b11a7a106f
1 changed files with 5 additions and 3 deletions

View File

@ -321,10 +321,12 @@ void Writev(const char* channelName, const char* functionName, LOGLEVEL level, c
va_copy(apCopy, ap);
#ifdef WIN32
u32 requiredSize = static_cast<u32>(_vscprintf(format, ap));
u32 requiredSize = static_cast<u32>(_vscprintf(format, apCopy));
#else
u32 requiredSize = std::vsnprintf(nullptr, 0, format, ap);
u32 requiredSize = std::vsnprintf(nullptr, 0, format, apCopy);
#endif
va_end(apCopy);
if (requiredSize < 256)
{
char buffer[256];
@ -340,4 +342,4 @@ void Writev(const char* channelName, const char* functionName, LOGLEVEL level, c
}
}
} // namespace Log
} // namespace Log