Fix of by one errors and set the position after the last char to a null byte.

This commit is contained in:
2026-02-19 00:34:34 +01:00
parent 7692e598d6
commit 45150c8ce3
@@ -123,10 +123,11 @@ void fsfwPrint(const sif::PrintLevel printType, const char* fmt, va_list arg) {
if (replaceLastCharWithNewline) {
const size_t stringLength = strlen(bufferPosition);
const size_t lastCharPosition =
etl::min(stringLength - 1, fsfwconfig::FSFW_PRINT_BUFFER_SIZE - 2);
etl::min(stringLength - 1, fsfwconfig::FSFW_PRINT_BUFFER_SIZE - 3);
const char lastChar = printBufferArray[bufferIdx][lastCharPosition];
if (!(lastChar == '\n' or lastChar == '\r')) {
printBufferArray[bufferIdx][lastCharPosition] = '\n';
printBufferArray[bufferIdx][lastCharPosition + 1] = '\n';
printBufferArray[bufferIdx][lastCharPosition + 2] = 0;
}
}