mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-11 02:18:29 -04:00
HAL_AVR: fixed null termination of vsnprintf()
This commit is contained in:
parent
4fd3adbcb9
commit
a6b21443c4
@ -54,6 +54,10 @@ int AVRUtil::vsnprintf_P(char* str, size_t size, const prog_char_t *format,
|
|||||||
{
|
{
|
||||||
BufferPrinter buf(str, size);
|
BufferPrinter buf(str, size);
|
||||||
print_vprintf(&buf, 1,(const char*) format, ap);
|
print_vprintf(&buf, 1,(const char*) format, ap);
|
||||||
|
if (buf._offs < size) {
|
||||||
|
// null terminate if possible
|
||||||
|
str[buf._offs] = 0;
|
||||||
|
}
|
||||||
return (int) buf._offs;
|
return (int) buf._offs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user