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" "fmt"
"io/fs" "io/fs"
"log" "log"
"maps"
"net/url" "net/url"
"os" "os"
"path" "path"
@@ -133,7 +134,7 @@ func (g *Group) SetLocked(locked bool, message string) {
func (g *Group) Data() map[string]interface{} { func (g *Group) Data() map[string]interface{} {
g.mu.Lock() g.mu.Lock()
defer g.mu.Unlock() defer g.mu.Unlock()
return g.data return maps.Clone(g.data)
} }
func (g *Group) UpdateData(d map[string]interface{}) { func (g *Group) UpdateData(d map[string]interface{}) {
+2 -1
View File
@@ -7,6 +7,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"log" "log"
"maps"
"net" "net"
"os" "os"
"strings" "strings"
@@ -101,7 +102,7 @@ func (c *webClient) Permissions() []string {
} }
func (c *webClient) Data() map[string]interface{} { func (c *webClient) Data() map[string]interface{} {
return c.data return maps.Clone(c.data)
} }
func (c *webClient) SetPermissions(perms []string) { func (c *webClient) SetPermissions(perms []string) {