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

Merge pull request #17703 from aboch/np

Verify Endpoint.Info() before accessing it
This commit is contained in:
Brian Goff 2015-11-04 19:23:11 -05:00
commit f18c5e9714
2 changed files with 16 additions and 3 deletions

View file

@ -191,7 +191,11 @@ func buildNetworkResource(nw libnetwork.Network) *types.NetworkResource {
epl := nw.Endpoints() epl := nw.Endpoints()
for _, e := range epl { for _, e := range epl {
sb := e.Info().Sandbox() ei := e.Info()
if ei == nil {
continue
}
sb := ei.Sandbox()
if sb == nil { if sb == nil {
continue continue
} }
@ -233,7 +237,12 @@ func buildEndpointResource(e libnetwork.Endpoint) types.EndpointResource {
} }
er.EndpointID = e.ID() er.EndpointID = e.ID()
if iface := e.Info().Iface(); iface != nil { ei := e.Info()
if ei == nil {
return er
}
if iface := ei.Iface(); iface != nil {
if mac := iface.MacAddress(); mac != nil { if mac := iface.MacAddress(); mac != nil {
er.MacAddress = mac.String() er.MacAddress = mac.String()
} }

View file

@ -1191,7 +1191,11 @@ func (container *Container) disconnectFromNetwork(n libnetwork.Network) error {
) )
s := func(current libnetwork.Endpoint) bool { s := func(current libnetwork.Endpoint) bool {
if sb := current.Info().Sandbox(); sb != nil { epInfo := current.Info()
if epInfo == nil {
return false
}
if sb := epInfo.Sandbox(); sb != nil {
if sb.ContainerID() == container.ID { if sb.ContainerID() == container.ID {
ep = current ep = current
sbox = sb sbox = sb