From 9dc7fa9d52bddade0a6b8565fd36ddf22a905497 Mon Sep 17 00:00:00 2001 From: Jehiah Czebotar Date: Sat, 6 Feb 2016 00:41:15 -0500 Subject: [PATCH] httpHead: return error before referencying resp.Body --- acme/http.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/acme/http.go b/acme/http.go index 4eb8ee18..6933899b 100644 --- a/acme/http.go +++ b/acme/http.go @@ -33,9 +33,10 @@ func httpHead(url string) (resp *http.Response, err error) { req.Header.Set("User-Agent", userAgent()) resp, err = http.DefaultClient.Do(req) - if resp.Body != nil { - resp.Body.Close() + if err != nil { + return resp, err } + resp.Body.Close() return resp, err }