Skip to content

Commit 16fe316

Browse files
committed
fix race in in-memory storage implementation
Signed-off-by: James Munnelly <[email protected]>
1 parent 82b787e commit 16fe316

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

storage/memory.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,10 @@ func (m *MemoryFS) ReadFiles(volumeID string) (map[string][]byte, error) {
146146
if !ok {
147147
return nil, ErrNotFound
148148
}
149-
return vol, nil
149+
// make a copy of the map to ensure no races can occur
150+
cpy := make(map[string][]byte)
151+
for k, v := range vol {
152+
cpy[k] = v
153+
}
154+
return cpy, nil
150155
}

0 commit comments

Comments
 (0)