mirror of
https://github.com/containers/podman.git
synced 2025-06-23 18:59:30 +08:00
Fix potential leak on mid-stream read error
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user