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 {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	defer response.Body.Close()
 | 
			
		||||
 | 
			
		||||
	err = jsonmessage.DisplayJSONMessagesStream(response.Body, buildBuff, cli.outFd, cli.isTerminalOut, 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)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		body.Close()
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
	return archive.Archive(body), nil
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue