Skip to content

Commit 7e153f8

Browse files
committed
use copy bytes to avoid side effect
1 parent 5568b76 commit 7e153f8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kvdb/flushable/flushable.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (w *Flushable) Put(key []byte, value []byte) error {
7878
}
7979

8080
func (w *Flushable) put(key []byte, value []byte) {
81-
w.modified.Put(key, common.CopyBytes(value))
81+
w.modified.Put(common.CopyBytes(key), common.CopyBytes(value))
8282
*w.sizeEstimation += len(key) + len(value) + 128
8383
}
8484

@@ -128,7 +128,7 @@ func (w *Flushable) Delete(key []byte) error {
128128
}
129129

130130
func (w *Flushable) delete(key []byte) {
131-
w.modified.Put(key, nil)
131+
w.modified.Put(common.CopyBytes(key), nil)
132132
*w.sizeEstimation += len(key) + 128 // it should be (len(key) - len(old value)), but we'd need to read old value
133133
}
134134

0 commit comments

Comments
 (0)