From 9412f318745f79fd4a42e84030f964d4c54f31e0 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Mon, 11 Nov 2024 17:47:59 +0100 Subject: [PATCH] Lock mutex when setting the logger Add mutex locking to ensure thread-safety when setting the logger in the `smtp` package. This prevents potential race conditions and ensures that the logger is updated consistently in concurrent operations. --- smtp/smtp.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/smtp/smtp.go b/smtp/smtp.go index 4841ec8..ed86ac9 100644 --- a/smtp/smtp.go +++ b/smtp/smtp.go @@ -587,7 +587,9 @@ func (c *Client) SetLogger(l log.Logger) { if l == nil { return } + c.mutex.Lock() c.logger = l + c.mutex.Unlock() } // SetLogAuthData enables logging of authentication data in the Client.