From 2f5a49ded2bc9013dceeb2efed2de3e633a315f4 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Tue, 6 Feb 2018 12:29:54 +0000 Subject: [PATCH] core/app/crash: Fix a crash in the crash handler If the crash report fails to send, we'd end up taking down the entire server. As reported in #1580. --- core/app/crash/reporting/reporting.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/app/crash/reporting/reporting.go b/core/app/crash/reporting/reporting.go index 0f92539d38..7d08d34ae4 100644 --- a/core/app/crash/reporting/reporting.go +++ b/core/app/crash/reporting/reporting.go @@ -104,7 +104,9 @@ func (r Reporter) sendReport(body io.Reader, contentType, endpoint string) (stri client := &http.Client{} res, err := client.Do(req) - defer res.Body.Close() + if err == nil { + defer res.Body.Close() + } if err != nil || res.StatusCode != http.StatusOK { return "", fmt.Errorf("Failed to upload report request: %v (%v)", err, res.StatusCode) }