From cfe6f595b036c332843697413fce5b78104159af Mon Sep 17 00:00:00 2001 From: Dirk McCormick Date: Mon, 28 Sep 2020 16:35:37 +0200 Subject: [PATCH] fix: unsafe append in LoadTipSet --- chain/store/store.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chain/store/store.go b/chain/store/store.go index e68857e0b..6c93db7a0 100644 --- a/chain/store/store.go +++ b/chain/store/store.go @@ -472,16 +472,16 @@ func (cs *ChainStore) LoadTipSet(tsk types.TipSetKey) (*types.TipSet, error) { // Fetch tipset block headers from blockstore in parallel var eg errgroup.Group cids := tsk.Cids() - blks := make([]*types.BlockHeader, 0, len(cids)) - for _, c := range cids { - c := c + blks := make([]*types.BlockHeader, len(cids)) + for i, c := range cids { + i, c := i, c eg.Go(func() error { b, err := cs.GetBlock(c) if err != nil { return xerrors.Errorf("get block %s: %w", c, err) } - blks = append(blks, b) + blks[i] = b return nil }) }