summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason T. Greene <jason.greene@redhat.com>2022-07-19 14:06:47 -0500
committerJason T. Greene <jason.greene@redhat.com>2022-07-19 14:06:47 -0500
commita652659429850150c8447cf759e478f37529a84f (patch)
treed533e475bcd84137d9e9c59070c5e8a49c4ee1b3
parent21cf30f2f895a3c453760f800077b8f7dbfce23c (diff)
downloadpodman-a652659429850150c8447cf759e478f37529a84f.tar.gz
podman-a652659429850150c8447cf759e478f37529a84f.tar.bz2
podman-a652659429850150c8447cf759e478f37529a84f.zip
Fix potential leak on mid-stream read error
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
-rw-r--r--pkg/machine/fedora.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/pkg/machine/fedora.go b/pkg/machine/fedora.go
index 7ac4692e3..497265269 100644
--- a/pkg/machine/fedora.go
+++ b/pkg/machine/fedora.go
@@ -105,11 +105,11 @@ func getFedoraDownload(releaseURL string) (*url.URL, string, int64, error) {
return nil, "", -1, fmt.Errorf("get request failed: %s: %w", verURL.String(), err)
}
+ defer resp.Body.Close()
bytes, err := io.ReadAll(&io.LimitedReader{R: resp.Body, N: 1024})
if err != nil {
return nil, "", -1, fmt.Errorf("failed reading: %s: %w", verURL.String(), err)
}
- _ = resp.Body.Close()
return downloadURL, strings.TrimSpace(string(bytes)), contentLen, nil
}