From f7bf82368a96c7146ed15ee5857221acaf713646 Mon Sep 17 00:00:00 2001 From: Daniel McCarney Date: Mon, 31 Jul 2017 14:19:03 -0400 Subject: [PATCH] Return error from `sendHTTPRequest` immediately. (#2925) Prior to this commit the `httpResp` result of `sendHTTPRequest` was examined even in the case where `sendHTTPRequest` returns a non-nil error. This can cause a nil panic since the `httpResp` may be `nil` when the error is not. This commit returns an error from `Req()` immediately when `sendHTTPRequest` returns one. --- test/ocsp/helper/helper.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/ocsp/helper/helper.go b/test/ocsp/helper/helper.go index 956642809..bec8835df 100644 --- a/test/ocsp/helper/helper.go +++ b/test/ocsp/helper/helper.go @@ -122,6 +122,9 @@ func Req(fileName string) (*ocsp.Response, error) { http.DefaultClient.Timeout = 5 * time.Second httpResp, err := sendHTTPRequest(req, ocspURL) + if err != nil { + return nil, err + } fmt.Printf("HTTP %d\n", httpResp.StatusCode) for k, v := range httpResp.Header { for _, vv := range v {