Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

Commit

Permalink
swarm/shed: pass a new byte slice copy to index decode functions
Browse files Browse the repository at this point in the history
  • Loading branch information
janos committed Dec 20, 2018
1 parent ecb4c19 commit 2ea4725
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions swarm/shed/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,13 @@ func (f Index) Iterate(fn IndexIterFunc, options *IterateOptions) (err error) {
if !bytes.HasPrefix(key, prefix) {
break
}
keyItem, err := f.decodeKeyFunc(key)
// create a copy of key byte slice not to share leveldb underlaying slice array
keyItem, err := f.decodeKeyFunc(append([]byte(nil), key...))
if err != nil {
return err
}
valueItem, err := f.decodeValueFunc(keyItem, it.Value())
// create a copy of value byte slice not to share leveldb underlaying slice array
valueItem, err := f.decodeValueFunc(keyItem, append([]byte(nil), it.Value()...))
if err != nil {
return err
}
Expand Down

0 comments on commit 2ea4725

Please sign in to comment.