Close response body if we error out

This commit is contained in:
Vaibhav Kamra 2023-06-27 12:14:30 -07:00
parent 65ce91592b
commit cc6bee1f15

View File

@ -74,10 +74,12 @@ func downloadFile(
} }
if graph.IsMalwareResp(ctx, resp) { if graph.IsMalwareResp(ctx, resp) {
defer resp.Body.Close()
return nil, clues.New("malware detected").Label(graph.LabelsMalware) return nil, clues.New("malware detected").Label(graph.LabelsMalware)
} }
if resp != nil && (resp.StatusCode/100) != 2 { if resp != nil && (resp.StatusCode/100) != 2 {
defer resp.Body.Close()
// upstream error checks can compare the status with // upstream error checks can compare the status with
// clues.HasLabel(err, graph.LabelStatus(http.KnownStatusCode)) // clues.HasLabel(err, graph.LabelStatus(http.KnownStatusCode))
return nil, clues. return nil, clues.