Open
Description
void AsciiString::format_va(const AsciiString& format, va_list args)
{
validate();
char buf[MAX_FORMAT_BUF_LEN];
if (_vsnprintf(buf, sizeof(buf)/sizeof(char)-1, format.str(), args) < 0)
throw ERROR_OUT_OF_MEMORY;
set(buf);
validate();
}
vsnprintf function always writes a null terminator, even if it truncates the output. When you use _vsnprintf and _vsnwprintf, the buffer is null-terminated only if there's room at the end (that is, if the number of characters to write is less than count)
We either need to use vsnprintf
with len(buf) or zero terminate buf with _vsnprintf
with len(buf)-1