store/file: fix segmentation violation bug (#2013)
This commit is contained in:
parent
99ba8dd7d4
commit
5469df1d7b
9
blob.go
9
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
|
// look for the blob within the bucket
|
||||||
value = bucket.Get([]byte(key))
|
res := bucket.Get([]byte(key))
|
||||||
if value == nil {
|
if res == nil {
|
||||||
return store.ErrNotFound
|
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
|
return nil
|
||||||
}
|
}
|
||||||
if err := db.View(readValue); err != nil {
|
if err := db.View(readValue); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user