Clone Group.Data and Client.Data.

This avoids a race condition.  Thanks to git-lul.
This commit is contained in:
Juliusz Chroboczek
2025-07-09 23:39:37 +02:00
parent 78872f3f6c
commit e7162642a7
2 changed files with 4 additions and 2 deletions
+2 -1
View File
@@ -6,6 +6,7 @@ import (
"fmt"
"io/fs"
"log"
"maps"
"net/url"
"os"
"path"
@@ -133,7 +134,7 @@ func (g *Group) SetLocked(locked bool, message string) {
func (g *Group) Data() map[string]interface{} {
g.mu.Lock()
defer g.mu.Unlock()
return g.data
return maps.Clone(g.data)
}
func (g *Group) UpdateData(d map[string]interface{}) {
+2 -1
View File
@@ -7,6 +7,7 @@ import (
"errors"
"fmt"
"log"
"maps"
"net"
"os"
"strings"
@@ -101,7 +102,7 @@ func (c *webClient) Permissions() []string {
}
func (c *webClient) Data() map[string]interface{} {
return c.data
return maps.Clone(c.data)
}
func (c *webClient) SetPermissions(perms []string) {