Merge pull request #3441 from nspcc-dev/boltdb-clone

This commit is contained in:
Roman Khimov 2024-05-16 19:49:11 +03:00 committed by GitHub
commit 0b69901d1e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -77,11 +77,8 @@ func NewBoltDBStore(cfg dbconfig.BoltDBOptions) (*BoltDBStore, error) {
func (s *BoltDBStore) Get(key []byte) (val []byte, err error) { func (s *BoltDBStore) Get(key []byte) (val []byte, err error) {
err = s.db.View(func(tx *bbolt.Tx) error { err = s.db.View(func(tx *bbolt.Tx) error {
b := tx.Bucket(Bucket) b := tx.Bucket(Bucket)
val = b.Get(key)
// Value from Get is only valid for the lifetime of transaction, #1482 // Value from Get is only valid for the lifetime of transaction, #1482
if val != nil { val = bytes.Clone(b.Get(key))
val = bytes.Clone(val)
}
return nil return nil
}) })
if val == nil { if val == nil {