mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2024-11-22 05:45:38 +00:00
fix segfault in CMultiLogger
vsprintf may change its va_list argument so repeatedly calling it with the same va_list arg is undefined behavior. Fix this by creating a copy of the va_list argument before each vsprintf call.
This commit is contained in:
parent
e59ecea32d
commit
1bb7de1dd9
|
@ -168,7 +168,10 @@ void CMultiLogger::DebugLog(const char *fmt, va_list vl)
|
||||||
{
|
{
|
||||||
for (auto &logger: m_loggers)
|
for (auto &logger: m_loggers)
|
||||||
{
|
{
|
||||||
logger->DebugLog(fmt, vl);
|
va_list vl_tmp;
|
||||||
|
va_copy(vl_tmp, vl);
|
||||||
|
logger->DebugLog(fmt, vl_tmp);
|
||||||
|
va_end(vl_tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +179,10 @@ void CMultiLogger::InfoLog(const char *fmt, va_list vl)
|
||||||
{
|
{
|
||||||
for (auto &logger: m_loggers)
|
for (auto &logger: m_loggers)
|
||||||
{
|
{
|
||||||
logger->InfoLog(fmt, vl);
|
va_list vl_tmp;
|
||||||
|
va_copy(vl_tmp, vl);
|
||||||
|
logger->InfoLog(fmt, vl_tmp);
|
||||||
|
va_end(vl_tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +190,10 @@ void CMultiLogger::ErrorLog(const char *fmt, va_list vl)
|
||||||
{
|
{
|
||||||
for (auto &logger: m_loggers)
|
for (auto &logger: m_loggers)
|
||||||
{
|
{
|
||||||
logger->ErrorLog(fmt, vl);
|
va_list vl_tmp;
|
||||||
|
va_copy(vl_tmp, vl);
|
||||||
|
logger->ErrorLog(fmt, vl_tmp);
|
||||||
|
va_end(vl_tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,4 +400,4 @@ void CSystemLogger::ErrorLog(const char *fmt, va_list vl)
|
||||||
CSystemLogger::CSystemLogger(CLogger::LogLevel level)
|
CSystemLogger::CSystemLogger(CLogger::LogLevel level)
|
||||||
: m_logLevel(level)
|
: m_logLevel(level)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue