diff --git a/src/trace.c b/src/trace.c index 6a2282d4..c3a1458c 100644 --- a/src/trace.c +++ b/src/trace.c @@ -64,13 +64,13 @@ static int64_t _trace_ts() static void _trace_append(tf_trace_t* trace, const char* buffer, size_t size) { - if (trace->write_offset + size >= k_buffer_size) + if (trace->write_offset + size + 2 >= k_buffer_size) { trace->buffer[trace->write_offset] = '\0'; trace->write_offset = 0; } - if (trace->write_offset + size < k_buffer_size) + if (trace->write_offset + size + 2 < k_buffer_size) { memcpy(trace->buffer + trace->write_offset, buffer, size); trace->write_offset += size;