Skip to content

Fix possible panic if NetworkConfig is nil#2790

Merged
dperny merged 1 commit intomoby:masterfrom
thaJeztah:fix_possible_panic
Jan 2, 2019
Merged

Fix possible panic if NetworkConfig is nil#2790
dperny merged 1 commit intomoby:masterfrom
thaJeztah:fix_possible_panic

Conversation

@thaJeztah
Copy link
Member

This code can panic if config.NetworkConfig is nil; https://play.golang.org/p/FqfuJkpWUz9

package main

type NetworkConfig struct {
	DefaultAddrPool []string
}

type Config struct {
	NetworkConfig *NetworkConfig
}

func main() {
	config := Config{}
	config.NetworkConfig.DefaultAddrPool = append(config.NetworkConfig.DefaultAddrPool, "foo")
}

@thaJeztah
Copy link
Member Author

ping @dperny @selansen @anshulpundir PTAL

@codecov
Copy link

codecov bot commented Nov 26, 2018

Codecov Report

Merging #2790 into master will decrease coverage by 0.16%.
The diff coverage is 0%.

@@            Coverage Diff             @@
##           master    #2790      +/-   ##
==========================================
- Coverage   62.02%   61.86%   -0.17%     
==========================================
  Files         137      137              
  Lines       22089    22093       +4     
==========================================
- Hits        13701    13668      -33     
- Misses       6905     6953      +48     
+ Partials     1483     1472      -11

@thaJeztah thaJeztah requested a review from dperny November 27, 2018 18:28
@dperny
Copy link
Collaborator

dperny commented Jan 2, 2019

LGTM.

@dperny dperny merged commit 08d6e4a into moby:master Jan 2, 2019
@thaJeztah thaJeztah deleted the fix_possible_panic branch January 3, 2019 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants