mirror of
https://github.com/containers/podman.git
synced 2026-02-06 04:11:53 -05:00
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>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user