From 050e3c51b091d1d5354d8bc2ba13b29e53837ace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20I=C3=B1iguez=20Goia?= Date: Sun, 31 Dec 2023 20:12:44 +0100 Subject: [PATCH] fixed leak dispatching alerts Fixed potential leak when disconnecting from the GUI, and at the same time dispatching an alert/message to the GUI. --- daemon/ui/alerts.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/daemon/ui/alerts.go b/daemon/ui/alerts.go index 2bb8ae90..1496979a 100644 --- a/daemon/ui/alerts.go +++ b/daemon/ui/alerts.go @@ -116,7 +116,10 @@ func (c *Client) alertsDispatcher() { } func (c *Client) dispatchAlert(pbAlert protocol.Alert) { - if c.client == nil { + c.RLock() + isDisconnected := c.client == nil + c.RUnlock() + if isDisconnected { return } ctx, cancel := context.WithTimeout(context.Background(), time.Second)