handle nil pointer in ec2 discovery (#4469)

This handles a nil pointer that was being accessed in EC2 discovery.

Fixes: #4441

Signed-off-by: noqcks <benny@noqcks.io>
This commit is contained in:
Benji Visser 2018-08-07 03:35:22 -04:00 committed by Brian Brazil
parent 8bb6e0dd6e
commit 46fb4078a6
1 changed files with 3 additions and 0 deletions

View File

@ -263,6 +263,9 @@ func (d *Discovery) refresh() (tg *targetgroup.Group, err error) {
var subnets []string
subnetsMap := make(map[string]struct{})
for _, eni := range inst.NetworkInterfaces {
if eni.SubnetId == nil {
continue
}
if _, ok := subnetsMap[*eni.SubnetId]; !ok {
subnetsMap[*eni.SubnetId] = struct{}{}
subnets = append(subnets, *eni.SubnetId)