[#704] Fix nil pointer dereference on decReader

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-09-07 15:41:45 +03:00 committed by Alex Vanin
parent 5184ed66c6
commit ffd259671a

View file

@ -449,7 +449,10 @@ func (n *layer) GetObject(ctx context.Context, p *GetObjectParams) error {
// copy full payload // copy full payload
written, err := io.CopyBuffer(p.Writer, r, buf) written, err := io.CopyBuffer(p.Writer, r, buf)
if err != nil { 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 return nil