diff options
author | Iskander (Alex) Sharipov <quasilyte@gmail.com> | 2018-12-11 16:33:23 +0300 |
---|---|---|
committer | Iskander Sharipov <quasilyte@gmail.com> | 2018-12-11 16:37:16 +0300 |
commit | a5c185b99404ea3fbab47ff9d7ba143392566bc1 (patch) | |
tree | a87b0bd9f7f007362da50d6637d16f34ebad1d89 /registry/registry.go | |
parent | 4555ae59e45bc1ef759985ac912f4988639dbeeb (diff) | |
download | docker-a5c185b99404ea3fbab47ff9d7ba143392566bc1.tar.gz |
registry: use len(via)!=0 instead of via!=nil
This avoids the corner case where `via` is not nil, but has a length of 0,
so the updated code does not panic in that situation.
Signed-off-by: Iskander Sharipov <quasilyte@gmail.com>
Diffstat (limited to 'registry/registry.go')
-rw-r--r-- | registry/registry.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/registry/registry.go b/registry/registry.go index 7a84bbfb7e..6727b7dc32 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -145,7 +145,7 @@ func trustedLocation(req *http.Request) bool { // addRequiredHeadersToRedirectedRequests adds the necessary redirection headers // for redirected requests func addRequiredHeadersToRedirectedRequests(req *http.Request, via []*http.Request) error { - if via != nil && via[0] != nil { + if len(via) != 0 && via[0] != nil { if trustedLocation(req) && trustedLocation(via[0]) { req.Header = via[0].Header return nil |