Browse Source

case on possible nil value dereference

Mohammed Nafees 3 years ago
parent
commit
a6ee918a58
1 changed files with 2 additions and 8 deletions
  1. 2 8
      internal/registry/registry.go

+ 2 - 8
internal/registry/registry.go

@@ -707,11 +707,9 @@ func (r *Registry) GetECRPaginatedImages(
 	imageIDMap := make(map[string]bool)
 
 	for _, id := range resp.ImageIds {
-		if id == nil {
-			continue
+		if id != nil && id.ImageTag != nil {
+			imageIDMap[*id.ImageTag] = true
 		}
-
-		imageIDMap[*id.ImageTag] = true
 	}
 
 	var wg sync.WaitGroup
@@ -750,10 +748,6 @@ func (r *Registry) GetECRPaginatedImages(
 	imageInfoMap := make(map[string]*ptypes.Image)
 
 	for _, img := range imageDetails {
-		if img == nil {
-			continue
-		}
-
 		for _, tag := range img.ImageTags {
 			newImage := &ptypes.Image{
 				Digest:         *img.ImageDigest,