value.Walk: fix data race

Acquire a read lock when walking through a CUE value.

Fixes #1494

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi 2022-01-24 18:02:05 -08:00
parent 6ce362be5d
commit e38be1a1fc

View File

@ -185,7 +185,10 @@ func (v *Value) IsConcreteR(opts ...cue.Option) error {
} }
func (v *Value) Walk(before func(*Value) bool, after func(*Value)) { func (v *Value) Walk(before func(*Value) bool, after func(*Value)) {
// FIXME: lock? // FIXME: this is a long lock
v.cc.rlock()
defer v.cc.runlock()
var ( var (
llBefore func(cue.Value) bool llBefore func(cue.Value) bool
llAfter func(cue.Value) llAfter func(cue.Value)