HAL_AVR: fixed null termination of vsnprintf()

This commit is contained in:
Andrew Tridgell 2013-03-22 11:53:24 +11:00
parent 4fd3adbcb9
commit a6b21443c4
1 changed files with 4 additions and 0 deletions

View File

@ -54,6 +54,10 @@ int AVRUtil::vsnprintf_P(char* str, size_t size, const prog_char_t *format,
{
BufferPrinter buf(str, size);
print_vprintf(&buf, 1,(const char*) format, ap);
if (buf._offs < size) {
// null terminate if possible
str[buf._offs] = 0;
}
return (int) buf._offs;
}