Browse Source

c8d/list: Initialize capacity instead of length

The slice which stores chain ids used for computing shared size was
mistakenly initialized with the length set instead of the capacity.
This caused a panic when iterating over it later and dereferncing nil
pointer from empty items.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Paweł Gronowski 2 years ago
parent
commit
391f9635cc
1 changed files with 1 additions and 1 deletions
  1. 1 1
      daemon/containerd/image_list.go

+ 1 - 1
daemon/containerd/image_list.go

@@ -61,7 +61,7 @@ func (i *ImageService) Images(ctx context.Context, opts types.ImageListOptions)
 		layers    map[digest.Digest]int
 	)
 	if opts.SharedSize {
-		root = make([]*[]digest.Digest, len(imgs))
+		root = make([]*[]digest.Digest, 0, len(imgs))
 		layers = make(map[digest.Digest]int)
 	}
 	for n, img := range imgs {