Skip to content

Commit

Permalink
core/state: using slices.Clone (#29366)
Browse files Browse the repository at this point in the history
  • Loading branch information
cuiweixie authored Mar 28, 2024
1 parent 3754a6c commit 7481398
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package state
import (
"fmt"
"math/big"
"slices"
"sort"
"time"

Expand Down Expand Up @@ -243,9 +244,7 @@ func (s *StateDB) Logs() []*types.Log {
func (s *StateDB) AddPreimage(hash common.Hash, preimage []byte) {
if _, ok := s.preimages[hash]; !ok {
s.journal.append(addPreimageChange{hash: hash})
pi := make([]byte, len(preimage))
copy(pi, preimage)
s.preimages[hash] = pi
s.preimages[hash] = slices.Clone(preimage)
}
}

Expand Down

0 comments on commit 7481398

Please sign in to comment.