Fix an almost certain buffer overflow
This commit is contained in:
parent
d7d37ae137
commit
43c201d9d0
1 changed files with 1 additions and 1 deletions
|
@ -480,7 +480,7 @@ std::string FGLocale::localizedPrintf(const char* id, const char* resource, ...
|
||||||
std::string FGLocale::vlocalizedPrintf(const char* id, const char* resource, va_list args)
|
std::string FGLocale::vlocalizedPrintf(const char* id, const char* resource, va_list args)
|
||||||
{
|
{
|
||||||
std::string format = getLocalizedString(id, resource);
|
std::string format = getLocalizedString(id, resource);
|
||||||
int len = ::vsprintf(nullptr, format.c_str(), args);
|
int len = ::vsnprintf(nullptr, 0, format.c_str(), args);
|
||||||
char* buf = (char*) alloca(len);
|
char* buf = (char*) alloca(len);
|
||||||
::vsprintf(buf, format.c_str(), args);
|
::vsprintf(buf, format.c_str(), args);
|
||||||
return std::string(buf);
|
return std::string(buf);
|
||||||
|
|
Loading…
Add table
Reference in a new issue