see issue: https://github.com/cocos2d/cocos2d-x/issues/18724
This commit is contained in:
halx99 2018-03-20 10:13:33 +08:00 committed by minggo
parent 542f064c37
commit 6317e35f01
1 changed files with 3 additions and 3 deletions

View File

@ -47,7 +47,7 @@ std::string format(const char* format, ...)
std::string buffer(CC_VSNPRINTF_BUFFER_LENGTH, '\0');
va_start(args, format);
int nret = vsnprintf(&buffer.front(), buffer.length(), format, args);
int nret = vsnprintf(&buffer.front(), buffer.length() + 1, format, args);
va_end(args);
if (nret >= 0) {
@ -58,7 +58,7 @@ std::string format(const char* format, ...)
buffer.resize(nret);
va_start(args, format);
nret = vsnprintf(&buffer.front(), buffer.length(), format, args);
nret = vsnprintf(&buffer.front(), buffer.length() + 1, format, args);
va_end(args);
assert(nret == buffer.length());
@ -70,7 +70,7 @@ std::string format(const char* format, ...)
buffer.resize(buffer.length() * 3 / 2);
va_start(args, format);
nret = vsnprintf(&buffer.front(), buffer.length(), format, args);
nret = vsnprintf(&buffer.front(), buffer.length() + 1, format, args);
va_end(args);
} while (nret < 0);