ethdb/memorydb: avoid corrupting prefix slice in NewIterator

append(prefix, start...) can mutate the caller's prefix slice when it
has spare capacity. Build the start key with string concatenation
instead.
This commit is contained in:
Weixie Cui 2026-07-05 17:59:05 +08:00
parent e3b6d0c86f
commit 50bb1e7313

View file

@ -169,7 +169,7 @@ func (db *Database) NewIterator(prefix []byte, start []byte) ethdb.Iterator {
var (
pr = string(prefix)
st = string(append(prefix, start...))
st = string(prefix) + string(start)
keys = make([]string, 0, len(db.db))
values = make([][]byte, 0, len(db.db))
)