From 14c39b2b26a21a84e5b519f1e273404f8541f28e Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Tue, 13 Oct 2020 18:57:04 +0300 Subject: [PATCH] storage: fix Get for BoltDB, fix #1482 --- pkg/core/storage/boltdb_store.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/core/storage/boltdb_store.go b/pkg/core/storage/boltdb_store.go index fa906ce06..f4a38608d 100644 --- a/pkg/core/storage/boltdb_store.go +++ b/pkg/core/storage/boltdb_store.go @@ -61,6 +61,12 @@ func (s *BoltDBStore) Get(key []byte) (val []byte, err error) { err = s.db.View(func(tx *bbolt.Tx) error { b := tx.Bucket(Bucket) val = b.Get(key) + // Value from Get is only valid for the lifetime of transaction, #1482 + if val != nil { + var valcopy = make([]byte, len(val)) + copy(valcopy, val) + val = valcopy + } return nil }) if val == nil {