Browse Source

HAL_AVR: fixed null termination of vsnprintf()

master
Andrew Tridgell 12 years ago
parent
commit
a6b21443c4
  1. 4
      libraries/AP_HAL_AVR/Util.cpp

4
libraries/AP_HAL_AVR/Util.cpp

@ -54,6 +54,10 @@ int AVRUtil::vsnprintf_P(char* str, size_t size, const prog_char_t *format, @@ -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;
}

Loading…
Cancel
Save