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>
This commit is contained in:
Paweł Gronowski 2023-04-25 10:38:23 +02:00
parent 598c295707
commit 391f9635cc
No known key found for this signature in database
GPG key ID: B85EFCFE26DEF92A

View file

@ -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 {