Common/Log: Fix corrupted output/UB with va_copy
Fixes crashes on GCC9+ (#9), maybe others.
This commit is contained in:
parent
c72d86cf1b
commit
b11a7a106f
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue