Skip to content

Commit

Permalink
fix upper limit for pos in echo()
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Oct 25, 2024
1 parent c3f06ff commit f26afb6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion main/utils/uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ void echo(const char *format, ...) {
va_list args;
va_start(args, format);
const int num_chars = std::vsnprintf(buffer, sizeof(buffer) - 1, format, args);
int pos = std::min(num_chars, static_cast<int>(sizeof(buffer) - 1));
int pos = std::min(num_chars, static_cast<int>(sizeof(buffer) - 2));
va_end(args);

pos += std::sprintf(&buffer[pos], "\n");
Expand Down

0 comments on commit f26afb6

Please sign in to comment.