From 382dafefc0e92dfe042d7bdc10e2e050acae3b24 Mon Sep 17 00:00:00 2001 From: Allen Sun Date: Wed, 27 Sep 2017 13:58:48 +0800 Subject: [PATCH] fix a potential panic when map is nil Signed-off-by: Allen Sun --- image.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/image.go b/image.go index f46046d64..d333c44fa 100644 --- a/image.go +++ b/image.go @@ -80,10 +80,10 @@ func (i *image) Unpack(ctx context.Context, snapshotterName string) error { if err != nil { return err } + if info.Labels == nil { + info.Labels = map[string]string{} + } if info.Labels["containerd.io/uncompressed"] != layer.Diff.Digest.String() { - if info.Labels == nil { - info.Labels = map[string]string{} - } info.Labels["containerd.io/uncompressed"] = layer.Diff.Digest.String() if _, err := cs.Update(ctx, info, "labels.containerd.io/uncompressed"); err != nil { return err