mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
*: fix response body leaks
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
2b1b235acf
commit
f0d83c4cdb
5 changed files with 4 additions and 4 deletions
|
@ -236,6 +236,7 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
|
|
||||||
err = jsonmessage.DisplayJSONMessagesStream(response.Body, buildBuff, cli.outFd, cli.isTerminalOut, nil)
|
err = jsonmessage.DisplayJSONMessagesStream(response.Body, buildBuff, cli.outFd, cli.isTerminalOut, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -161,7 +161,6 @@ func (d *graphDriverProxy) Diff(id, parent string) (archive.Archive, error) {
|
||||||
}
|
}
|
||||||
body, err := d.client.Stream("GraphDriver.Diff", args)
|
body, err := d.client.Stream("GraphDriver.Diff", args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
body.Close()
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return archive.Archive(body), nil
|
return archive.Archive(body), nil
|
||||||
|
|
|
@ -174,9 +174,7 @@ func (l *splunkLogger) Log(msg *logger.Message) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if res.Body != nil {
|
defer res.Body.Close()
|
||||||
defer res.Body.Close()
|
|
||||||
}
|
|
||||||
if res.StatusCode != http.StatusOK {
|
if res.StatusCode != http.StatusOK {
|
||||||
var body []byte
|
var body []byte
|
||||||
body, err = ioutil.ReadAll(res.Body)
|
body, err = ioutil.ReadAll(res.Body)
|
||||||
|
|
|
@ -101,6 +101,7 @@ func (c *Client) SendFile(serviceMethod string, data io.Reader, ret interface{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer body.Close()
|
||||||
if err := json.NewDecoder(body).Decode(&ret); err != nil {
|
if err := json.NewDecoder(body).Decode(&ret); err != nil {
|
||||||
logrus.Errorf("%s: error reading plugin resp: %v", serviceMethod, err)
|
logrus.Errorf("%s: error reading plugin resp: %v", serviceMethod, err)
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -284,6 +284,7 @@ func (r *Session) GetRemoteImageLayer(imgID, registry string, imgSize int64) (io
|
||||||
res, err = r.client.Do(req)
|
res, err = r.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Debugf("Error contacting registry %s: %v", registry, err)
|
logrus.Debugf("Error contacting registry %s: %v", registry, err)
|
||||||
|
// the only case err != nil && res != nil is https://golang.org/src/net/http/client.go#L515
|
||||||
if res != nil {
|
if res != nil {
|
||||||
if res.Body != nil {
|
if res.Body != nil {
|
||||||
res.Body.Close()
|
res.Body.Close()
|
||||||
|
|
Loading…
Add table
Reference in a new issue