diff --git a/src/trace.cpp b/src/trace.cpp index 065c6da..896dbaa 100644 --- a/src/trace.cpp +++ b/src/trace.cpp @@ -47,10 +47,10 @@ static TraceLine &trace_line(uint16_t index) static void print(uint8_t severity, const char *buffer, int length) { - char lin[(MAX_LINE_LEN * 4) + 1]; + char lin[MAX_LINE_LEN + 1]; int lineptr = 0; - while (0 != *buffer) + while ((0 != *buffer) && (lineptr < (sizeof(lin) - 1))) { if (*buffer > 0x1f) lin[lineptr] = *buffer; @@ -59,8 +59,6 @@ static void print(uint8_t severity, const char *buffer, int length) ++lineptr; ++buffer; } - if (lineptr > MAX_LINE_LEN) - lineptr = MAX_LINE_LEN; lin[lineptr] = 0; // ukoncime retezec TraceLine line(severity, lin, lineptr);