Skip to content

Commit

Permalink
Merge pull request #2327 from thaJeztah/18.09_backport_fix_crash
Browse files Browse the repository at this point in the history
[18.09 backport] Fix possible nil pointer exception
  • Loading branch information
Flavio Crisciani authored Jan 23, 2019
2 parents 2cfbf9b + d20ece4 commit 664e931
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
6 changes: 2 additions & 4 deletions default_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,8 @@ func (c *controller) defaultGwNetwork() (Network, error) {
defer func() { <-procGwNetwork }()

n, err := c.NetworkByName(libnGWNetwork)
if err != nil {
if _, ok := err.(types.NotFoundError); ok {
n, err = c.createGWNetwork()
}
if _, ok := err.(types.NotFoundError); ok {
n, err = c.createGWNetwork()
}
return n, err
}
Expand Down
8 changes: 3 additions & 5 deletions network.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,9 @@ func (n *network) validateConfiguration() error {
driverOptions map[string]string
opts interface{}
)
switch data.(type) {
case map[string]interface{}:
opts = data.(map[string]interface{})
case map[string]string:
opts = data.(map[string]string)
switch t := data.(type) {
case map[string]interface{}, map[string]string:
opts = t
}
ba, err := json.Marshal(opts)
if err != nil {
Expand Down
7 changes: 6 additions & 1 deletion networkdb/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,12 @@ func (nDB *NetworkDB) rejoinClusterBootStrap() {
return
}

myself, _ := nDB.nodes[nDB.config.NodeID]
myself, ok := nDB.nodes[nDB.config.NodeID]
if !ok {
nDB.RUnlock()
logrus.Warnf("rejoinClusterBootstrap unable to find local node info using ID:%v", nDB.config.NodeID)
return
}
bootStrapIPs := make([]string, 0, len(nDB.bootStrapIP))
for _, bootIP := range nDB.bootStrapIP {
// botostrap IPs are usually IP:port from the Join
Expand Down

0 comments on commit 664e931

Please sign in to comment.