From 58154c3600271a1f0d4798fc9a12a103dc0c949c Mon Sep 17 00:00:00 2001 From: rubyist Date: Wed, 8 Jul 2015 15:44:41 -0400 Subject: [PATCH] Check doHttpRequest() error in UploadObject() This method was not checking the error from doHttpRequest() yet still manipulating the reponse object and body. In some scenarios this can cause a panic when trying to read from the nil reponse body. Fixes #462 --- lfs/client.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lfs/client.go b/lfs/client.go index 0fc6407d..7a5a1266 100644 --- a/lfs/client.go +++ b/lfs/client.go @@ -341,8 +341,11 @@ func UploadObject(o *objectResource, cb CopyCallback) *WrappedError { req.ContentLength = int64(len(by)) req.Body = ioutil.NopCloser(bytes.NewReader(by)) res, wErr = doHttpRequest(req, creds) - LogTransfer("lfs.data.verify", res) + if wErr != nil { + return wErr + } + LogTransfer("lfs.data.verify", res) io.Copy(ioutil.Discard, res.Body) res.Body.Close()