1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix request.SockRequestRaw error check

We should check for error before reading the response (response can be
nil, and thus this would panic)

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
Vincent Demeester 2017-05-23 12:48:22 -07:00
parent b3d19cfc6a
commit 45e0376ea3
No known key found for this signature in database
GPG key ID: 083CC6FD6EB699A3

View file

@ -217,13 +217,14 @@ func SockRequestRaw(method, endpoint string, data io.Reader, ct, daemon string,
}
resp, err := client.Do(req)
if err != nil {
client.Close()
return resp, nil, err
}
body := ioutils.NewReadCloserWrapper(resp.Body, func() error {
defer resp.Body.Close()
return client.Close()
})
if err != nil {
client.Close()
}
return resp, body, err
}