From 5469df1d7b137d3fc73fc036cdb6d910ce3d7519 Mon Sep 17 00:00:00 2001 From: ben-toogood Date: Tue, 22 Sep 2020 10:00:14 +0100 Subject: [PATCH] store/file: fix segmentation violation bug (#2013) --- blob.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/blob.go b/blob.go index eb5c34c..4c7a0e5 100644 --- a/blob.go +++ b/blob.go @@ -59,11 +59,16 @@ func (b *blobStore) Read(key string, opts ...store.BlobOption) (io.Reader, error } // look for the blob within the bucket - value = bucket.Get([]byte(key)) - if value == nil { + res := bucket.Get([]byte(key)) + if res == nil { return store.ErrNotFound } + // the res object is only valid for the duration of the blot transaction, see: + // https://github.com/golang/go/issues/33047 + value = make([]byte, len(res)) + copy(value, res) + return nil } if err := db.View(readValue); err != nil {