*: fix response body leaks

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca 2016-03-16 16:38:13 +01:00
parent 2b1b235acf
commit f0d83c4cdb
5 changed files with 4 additions and 4 deletions

View File

@ -236,6 +236,7 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
if err != nil {
return err
}
defer response.Body.Close()
err = jsonmessage.DisplayJSONMessagesStream(response.Body, buildBuff, cli.outFd, cli.isTerminalOut, nil)
if err != nil {

View File

@ -161,7 +161,6 @@ func (d *graphDriverProxy) Diff(id, parent string) (archive.Archive, error) {
}
body, err := d.client.Stream("GraphDriver.Diff", args)
if err != nil {
body.Close()
return nil, err
}
return archive.Archive(body), nil

View File

@ -174,9 +174,7 @@ func (l *splunkLogger) Log(msg *logger.Message) error {
if err != nil {
return err
}
if res.Body != nil {
defer res.Body.Close()
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
var body []byte
body, err = ioutil.ReadAll(res.Body)

View File

@ -101,6 +101,7 @@ func (c *Client) SendFile(serviceMethod string, data io.Reader, ret interface{})
if err != nil {
return err
}
defer body.Close()
if err := json.NewDecoder(body).Decode(&ret); err != nil {
logrus.Errorf("%s: error reading plugin resp: %v", serviceMethod, err)
return err

View File

@ -284,6 +284,7 @@ func (r *Session) GetRemoteImageLayer(imgID, registry string, imgSize int64) (io
res, err = r.client.Do(req)
if err != nil {
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.Body != nil {
res.Body.Close()