summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSascha Grunert <sgrunert@suse.com>2019-07-25 12:45:08 +0200
committerSascha Grunert <sgrunert@suse.com>2019-07-25 12:45:08 +0200
commit7630f1b52efbefec463223e7631bee2ca007ce14 (patch)
tree35d58b1c8f4f08684526f2d2bedb73f569bfecb9
parent7c9095ea1de363f8d76ae246575062755ac9398e (diff)
downloadpodman-7630f1b52efbefec463223e7631bee2ca007ce14.tar.gz
podman-7630f1b52efbefec463223e7631bee2ca007ce14.tar.bz2
podman-7630f1b52efbefec463223e7631bee2ca007ce14.zip
Fix possible runtime panic if image history len is zero
We now return an empty string for the `Comment` field if an OCI v1 image contains no history. Signed-off-by: Sascha Grunert <sgrunert@suse.com>
-rw-r--r--libpod/image/image.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go
index db50e3dbd..068491f28 100644
--- a/libpod/image/image.go
+++ b/libpod/image/image.go
@@ -1298,7 +1298,10 @@ func (i *Image) Comment(ctx context.Context, manifestType string) (string, error
if err != nil {
return "", err
}
- return ociv1Img.History[0].Comment, nil
+ if len(ociv1Img.History) > 0 {
+ return ociv1Img.History[0].Comment, nil
+ }
+ return "", nil
}
// Save writes a container image to the filesystem