mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-26 15:45:42 +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 (;;)
|
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)))
|
if (ret < 0 || ((u32)ret >= (currentBufferSize - 1)))
|
||||||
{
|
{
|
||||||
currentBufferSize *= 2;
|
currentBufferSize *= 2;
|
||||||
|
|
|
@ -14,11 +14,15 @@ std::string StdStringFromFormat(const char* format, ...)
|
||||||
|
|
||||||
std::string StdStringFromFormatV(const char* format, std::va_list ap)
|
std::string StdStringFromFormatV(const char* format, std::va_list ap)
|
||||||
{
|
{
|
||||||
|
std::va_list ap_copy;
|
||||||
|
va_copy(ap_copy, ap);
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
int len = _vscprintf(format, ap);
|
int len = _vscprintf(format, ap_copy);
|
||||||
#else
|
#else
|
||||||
int len = std::vsnprintf(nullptr, 0, format, ap);
|
int len = std::vsnprintf(nullptr, 0, format, ap_copy);
|
||||||
#endif
|
#endif
|
||||||
|
va_end(ap_copy);
|
||||||
|
|
||||||
std::string ret;
|
std::string ret;
|
||||||
ret.resize(len);
|
ret.resize(len);
|
||||||
|
|
Loading…
Reference in a new issue