mirror of
https://github.com/PCSX2/pcsx2.git
synced 2026-10-30 19:16:52 +01:00
Common/StringUtil: Handle error returns in StdStringFromFormatV()
This commit is contained in:
1 parent
b1d6d84e6f
commit
c07c942659
1 file changed
+8
-2
@@ -49,8 +49,14 @@ namespace StringUtil
|
||||
va_end(ap_copy);
|
||||
|
||||
std::string ret;
|
||||
ret.resize(len);
|
||||
std::vsnprintf(ret.data(), ret.size() + 1, format, ap);
|
||||
|
||||
// If an encoding error occurs, len is -1. Which we definitely don't want to resize to.
|
||||
if (len > 0)
|
||||
{
|
||||
ret.resize(len);
|
||||
std::vsnprintf(ret.data(), ret.size() + 1, format, ap);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user