浏览代码

fix nil pointer dereference (#13221)

Mitsuhiro Tanda 7 年之前
父节点
当前提交
28250271cc
共有 1 个文件被更改,包括 3 次插入0 次删除
  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")
 					}
 					v = v.FieldByName(key)
+					if !v.IsValid() {
+						return nil, errors.New("invalid attribute path")
+					}
 				}
 				if attr, ok := v.Interface().(*string); ok {
 					data = *attr