mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 00:55:55 +00:00
Make a copy of returned attribute map for safety.
This commit is contained in:
parent
efda804851
commit
9dda9cbc2b
1 changed files with 11 additions and 1 deletions
12
attr.go
12
attr.go
|
|
@ -49,7 +49,17 @@ type AttrCache struct {
|
|||
func (c *AttrCache) Get(id uint64) map[string]interface{} {
|
||||
c.mu.RLock()
|
||||
defer c.mu.RUnlock()
|
||||
return c.attrs[id]
|
||||
attrs := c.attrs[id]
|
||||
if attrs == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Make a copy for safety
|
||||
ret := make(map[string]interface{})
|
||||
for k, v := range attrs {
|
||||
ret[k] = v
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
// Set updates the cached attributes for a given id.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue