store/file: fix segmentation violation bug (#2013)

This commit is contained in:
ben-toogood 2020-09-22 10:00:14 +01:00 committed by Vasiliy Tolstov
parent 99ba8dd7d4
commit 5469df1d7b

View File

@ -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 {