forked from TrueCloudLab/neoneo-go
core: fix key clashes in Storage.Find
Fixes #1873. NewByteArray() doesn't copy the slice, so we need to do it ourselves.
This commit is contained in:
parent
d33dcd557a
commit
e2121ff583
1 changed files with 4 additions and 1 deletions
|
@ -49,7 +49,10 @@ func storageFind(ic *interop.Context) error {
|
||||||
|
|
||||||
filteredMap := stackitem.NewMap()
|
filteredMap := stackitem.NewMap()
|
||||||
for k, v := range siMap {
|
for k, v := range siMap {
|
||||||
filteredMap.Add(stackitem.NewByteArray(append(prefix, []byte(k)...)), stackitem.NewByteArray(v))
|
key := append(prefix, []byte(k)...)
|
||||||
|
keycopy := make([]byte, len(key))
|
||||||
|
copy(keycopy, key)
|
||||||
|
filteredMap.Add(stackitem.NewByteArray(keycopy), stackitem.NewByteArray(v))
|
||||||
}
|
}
|
||||||
sort.Slice(filteredMap.Value().([]stackitem.MapElement), func(i, j int) bool {
|
sort.Slice(filteredMap.Value().([]stackitem.MapElement), func(i, j int) bool {
|
||||||
return bytes.Compare(filteredMap.Value().([]stackitem.MapElement)[i].Key.Value().([]byte),
|
return bytes.Compare(filteredMap.Value().([]stackitem.MapElement)[i].Key.Value().([]byte),
|
||||||
|
|
Loading…
Reference in a new issue