From 9c413e3e6f1c6bd6abada707c442862049d29743 Mon Sep 17 00:00:00 2001 From: unclejack Date: Wed, 3 Sep 2014 17:26:56 +0300 Subject: [PATCH] registry/session: fix panic in GetRemoteImageLayer Docker-DCO-1.1-Signed-off-by: Cristian Staretu (github: unclejack) --- registry/session.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/registry/session.go b/registry/session.go index 82b931f2692b7..a8ade7053af47 100644 --- a/registry/session.go +++ b/registry/session.go @@ -167,7 +167,9 @@ func (r *Session) GetRemoteImageLayer(imgID, registry string, token []string, im for i := 1; i <= retries; i++ { res, client, err = r.doRequest(req) if err != nil { - res.Body.Close() + if res.Body != nil { + res.Body.Close() + } if i == retries { return nil, fmt.Errorf("Server error: Status %d while fetching image layer (%s)", res.StatusCode, imgID)