From ffd259671a65b182173a62c2c68d9c071236ff4d Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Wed, 7 Sep 2022 15:41:45 +0300 Subject: [PATCH] [#704] Fix nil pointer dereference on decReader Signed-off-by: Denis Kirillov --- api/layer/layer.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/layer/layer.go b/api/layer/layer.go index 185dba8db..eb731293f 100644 --- a/api/layer/layer.go +++ b/api/layer/layer.go @@ -449,7 +449,10 @@ func (n *layer) GetObject(ctx context.Context, p *GetObjectParams) error { // copy full payload written, err := io.CopyBuffer(p.Writer, r, buf) if err != nil { - return fmt.Errorf("copy object payload written: '%d', decLength: '%d', params.ln: '%d' : %w", written, decReader.DecryptedLength(), params.ln, err) + if decReader != nil { + return fmt.Errorf("copy object payload written: '%d', decLength: '%d', params.ln: '%d' : %w", written, decReader.DecryptedLength(), params.ln, err) + } + return fmt.Errorf("copy object payload written: '%d': %w", written, err) } return nil