mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 13:55:38 +00:00
Common/StringUtil: Fix more incorrect usage of va_list
This commit is contained in:
parent
899a8e0f03
commit
4eadc07629
|
@ -328,7 +328,10 @@ void String::AppendFormattedStringVA(const char* FormatString, va_list ArgPtr)
|
|||
|
||||
for (;;)
|
||||
{
|
||||
int ret = std::vsnprintf(pBuffer, currentBufferSize, FormatString, ArgPtr);
|
||||
va_list ArgPtrCopy;
|
||||
va_copy(ArgPtrCopy, ArgPtr);
|
||||
int ret = std::vsnprintf(pBuffer, currentBufferSize, FormatString, ArgPtrCopy);
|
||||
va_end(ArgPtrCopy);
|
||||
if (ret < 0 || ((u32)ret >= (currentBufferSize - 1)))
|
||||
{
|
||||
currentBufferSize *= 2;
|
||||
|
|
|
@ -14,11 +14,15 @@ std::string StdStringFromFormat(const char* format, ...)
|
|||
|
||||
std::string StdStringFromFormatV(const char* format, std::va_list ap)
|
||||
{
|
||||
std::va_list ap_copy;
|
||||
va_copy(ap_copy, ap);
|
||||
|
||||
#ifdef WIN32
|
||||
int len = _vscprintf(format, ap);
|
||||
int len = _vscprintf(format, ap_copy);
|
||||
#else
|
||||
int len = std::vsnprintf(nullptr, 0, format, ap);
|
||||
int len = std::vsnprintf(nullptr, 0, format, ap_copy);
|
||||
#endif
|
||||
va_end(ap_copy);
|
||||
|
||||
std::string ret;
|
||||
ret.resize(len);
|
||||
|
|
Loading…
Reference in a new issue