diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index bd6c37a7b5..505ce61eca 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -573,6 +573,9 @@ void taosPrintSlowLog(const char *format, ...) { len += vsnprintf(buffer + len, LOG_MAX_LINE_DUMP_BUFFER_SIZE - 2 - len, format, argpointer); va_end(argpointer); + if (len < 0 || len > LOG_MAX_LINE_DUMP_BUFFER_SIZE - 2) { + len = LOG_MAX_LINE_DUMP_BUFFER_SIZE - 2; + } buffer[len++] = '\n'; buffer[len] = 0;