Selaa lähdekoodia

fix nil pointer dereference (#13221)

Mitsuhiro Tanda 7 vuotta sitten
vanhempi
commit
28250271cc
1 muutettua tiedostoa jossa 3 lisäystä ja 0 poistoa
  1. 3 0
      pkg/tsdb/cloudwatch/metric_find_query.go

+ 3 - 0
pkg/tsdb/cloudwatch/metric_find_query.go

@@ -466,6 +466,9 @@ func (e *CloudWatchExecutor) handleGetEc2InstanceAttribute(ctx context.Context,
 						return nil, errors.New("invalid attribute path")
 						return nil, errors.New("invalid attribute path")
 					}
 					}
 					v = v.FieldByName(key)
 					v = v.FieldByName(key)
+					if !v.IsValid() {
+						return nil, errors.New("invalid attribute path")
+					}
 				}
 				}
 				if attr, ok := v.Interface().(*string); ok {
 				if attr, ok := v.Interface().(*string); ok {
 					data = *attr
 					data = *attr