Fix of by one errors and set the position after the last char to a null byte.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user