From 45150c8ce3555f33eb13ec1f3434bca8d744cad4 Mon Sep 17 00:00:00 2001 From: Christian Ritzmann Date: Thu, 19 Feb 2026 00:34:34 +0100 Subject: [PATCH] Fix of by one errors and set the position after the last char to a null byte. --- src/fsfw/serviceinterface/ServiceInterfacePrinter.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/fsfw/serviceinterface/ServiceInterfacePrinter.cpp b/src/fsfw/serviceinterface/ServiceInterfacePrinter.cpp index 6e30cbef..373aa7d7 100644 --- a/src/fsfw/serviceinterface/ServiceInterfacePrinter.cpp +++ b/src/fsfw/serviceinterface/ServiceInterfacePrinter.cpp @@ -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; } }