From 3a58b7bac63349b938c76a6c07ca5275d92bb0bd Mon Sep 17 00:00:00 2001 From: chrislu Date: Sat, 26 Feb 2022 03:23:06 -0800 Subject: [PATCH] a little safer --- weed/filer/filechunk_manifest.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/weed/filer/filechunk_manifest.go b/weed/filer/filechunk_manifest.go index 2c9dc5e74..372901b7d 100644 --- a/weed/filer/filechunk_manifest.go +++ b/weed/filer/filechunk_manifest.go @@ -124,8 +124,10 @@ func retriedFetchChunkData(buffer []byte, urlStrings []string, cipherKey []byte, urlString = url.PathEscape(urlString) } shouldRetry, err = util.ReadUrlAsStream(urlString+"?readDeleted=true", cipherKey, isGzipped, isFullChunk, offset, len(buffer), func(data []byte) { - x := copy(buffer[n:], data) - n += x + if n < len(buffer) { + x := copy(buffer[n:], data) + n += x + } }) if !shouldRetry { break