Skip to content

Commit 5c78ed8

Browse files
committed
returned objects of reference type should be unchangeable
Signed-off-by: Bruce Ma <[email protected]>
1 parent c46b410 commit 5c78ed8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/cache/informer_cache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ func indexByField(indexer Informer, field string, extractor client.IndexerFunc)
193193
rawVals := extractor(obj)
194194
var vals []string
195195
if ns == "" {
196-
// if we're not doubling the keys for the namespaced case, just re-use what was returned to us
197-
vals = rawVals
196+
// if we're not doubling the keys for the namespaced case, just create a new slice with same length
197+
vals = make([]string, len(rawVals))
198198
} else {
199199
// if we need to add non-namespaced versions too, double the length
200200
vals = make([]string, len(rawVals)*2)

0 commit comments

Comments
 (0)