Skip to content

Commit 2dc44e9

Browse files
committed
cardinality: comment when copy buf to prefixKey
1 parent 5431b22 commit 2dc44e9

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

plugin/action/cardinality/cardinality.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ func (p *Plugin) Do(event *pipeline.Event) pipeline.ActionResult {
265265
p.buf = p.buf[:0]
266266
p.buf = p.keys.appendTo(p.buf)
267267
prefixKey := make([]byte, len(p.buf))
268+
// make an independent copy so prefixKey won't be corrupted when p.buf is reused or modified.
268269
copy(prefixKey, p.buf)
269270

270271
keysCount := p.cache.CountPrefix(string(prefixKey))

0 commit comments

Comments
 (0)