From ab070f2ebee287e6cddf9b43bc2abac77e9eeb9b Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 22 Sep 2020 11:09:41 -0700 Subject: [PATCH] copy actor object when iterating over actors This is a pretty big footgun. --- chain/state/statetree.go | 1 + 1 file changed, 1 insertion(+) diff --git a/chain/state/statetree.go b/chain/state/statetree.go index fb6a14a9b..a654d224b 100644 --- a/chain/state/statetree.go +++ b/chain/state/statetree.go @@ -385,6 +385,7 @@ func (st *StateTree) MutateActor(addr address.Address, f func(*types.Actor) erro func (st *StateTree) ForEach(f func(address.Address, *types.Actor) error) error { var act types.Actor return st.root.ForEach(&act, func(k string) error { + act := act // copy addr, err := address.NewFromBytes([]byte(k)) if err != nil { return xerrors.Errorf("invalid address (%x) found in state tree key: %w", []byte(k), err)