浏览代码

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 年之前
父节点
当前提交
391f9635cc
共有 1 个文件被更改,包括 1 次插入1 次删除
  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 {