From cc6bee1f15bab964c1302cb53aa582525070cd6d Mon Sep 17 00:00:00 2001 From: Vaibhav Kamra Date: Tue, 27 Jun 2023 12:14:30 -0700 Subject: [PATCH] Close response body if we error out --- src/internal/m365/onedrive/item.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/internal/m365/onedrive/item.go b/src/internal/m365/onedrive/item.go index bf12e91c4..90f7589e1 100644 --- a/src/internal/m365/onedrive/item.go +++ b/src/internal/m365/onedrive/item.go @@ -74,10 +74,12 @@ func downloadFile( } if graph.IsMalwareResp(ctx, resp) { + defer resp.Body.Close() return nil, clues.New("malware detected").Label(graph.LabelsMalware) } if resp != nil && (resp.StatusCode/100) != 2 { + defer resp.Body.Close() // upstream error checks can compare the status with // clues.HasLabel(err, graph.LabelStatus(http.KnownStatusCode)) return nil, clues.