Skip to content

Commit d581dfe

Browse files
committed
ethdb: copy stored memdb values
Storing a value in LevelDB copies the bytes, modifying the value afterwards does not affect the content of the database. This commit ensures that MemDatabase satisfies the same property.
1 parent 8b32f10 commit d581dfe

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

ethdb/memory_database.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ func NewMemDatabase() (*MemDatabase, error) {
3636
}
3737

3838
func (db *MemDatabase) Put(key []byte, value []byte) error {
39-
db.db[string(key)] = value
40-
39+
db.db[string(key)] = common.CopyBytes(value)
4140
return nil
4241
}
4342

0 commit comments

Comments
 (0)