mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-17 12:21:38 +00:00
trie/bintrie: fix CollectNodes path slice aliasing
This commit is contained in:
parent
d5969de518
commit
05773f4bae
1 changed files with 8 additions and 2 deletions
|
|
@ -216,10 +216,16 @@ func (s *NodeStore) CollectNodes(ref NodeRef, path []byte, flushfn NodeFlushFn)
|
||||||
return nil
|
return nil
|
||||||
case KindInternal:
|
case KindInternal:
|
||||||
node := s.getInternal(ref.Index())
|
node := s.getInternal(ref.Index())
|
||||||
if err := s.CollectNodes(node.left, append(path, 0), flushfn); err != nil {
|
leftPath := make([]byte, len(path)+1)
|
||||||
|
copy(leftPath, path)
|
||||||
|
leftPath[len(path)] = 0
|
||||||
|
if err := s.CollectNodes(node.left, leftPath, flushfn); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := s.CollectNodes(node.right, append(path, 1), flushfn); err != nil {
|
rightPath := make([]byte, len(path)+1)
|
||||||
|
copy(rightPath, path)
|
||||||
|
rightPath[len(path)] = 1
|
||||||
|
if err := s.CollectNodes(node.right, rightPath, flushfn); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
flushfn(path, s.ComputeHash(ref), s.SerializeNode(ref))
|
flushfn(path, s.ComputeHash(ref), s.SerializeNode(ref))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue