浏览代码

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.
Felix Lange 10 年之前
父节点
当前提交
d581dfee5f
共有 1 个文件被更改,包括 1 次插入2 次删除
  1. 1 2
      ethdb/memory_database.go

+ 1 - 2
ethdb/memory_database.go

@@ -36,8 +36,7 @@ func NewMemDatabase() (*MemDatabase, error) {
 }
 
 func (db *MemDatabase) Put(key []byte, value []byte) error {
-	db.db[string(key)] = value
-
+	db.db[string(key)] = common.CopyBytes(value)
 	return nil
 }