diff --git a/src/common/log.cpp b/src/common/log.cpp index 4b05bef5a..b5df001e4 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -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(_vscprintf(format, ap)); + u32 requiredSize = static_cast(_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 \ No newline at end of file +} // namespace Log