From da76af187fbe86da0edd2e1bd5c25d9d4a45738c Mon Sep 17 00:00:00 2001 From: chrislu Date: Fri, 4 Mar 2022 22:36:01 -0800 Subject: [PATCH] mount: avoid possible index out of bounds error --- weed/filer/reader_cache.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/weed/filer/reader_cache.go b/weed/filer/reader_cache.go index 4f2c52303..bce97cc49 100644 --- a/weed/filer/reader_cache.go +++ b/weed/filer/reader_cache.go @@ -183,6 +183,10 @@ func (s *SingleChunkCacher) readChunkAt(buf []byte, offset int64) (int, error) { s.RLock() defer s.RUnlock() - return copy(buf, s.data[offset:]), s.err + if s.err != nil { + return 0, s.err + } + + return copy(buf, s.data[offset:]), nil }