diff --git a/lib/core/logs.c b/lib/core/logs.c
index 0ee1ae349..268b2e36b 100644
--- a/lib/core/logs.c
+++ b/lib/core/logs.c
@@ -126,6 +126,7 @@ _lwsl_emit_stderr(int level, const char *line, int ts)
 	if (!tty)
 		tty = isatty(2) | 2;
 
+	buf[0] = '\0';
 #if defined(LWS_LOGS_TIMESTAMP)
 	if (ts)
 		lwsl_timestamp(level, buf, sizeof(buf));