mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-08-18 14:28:01 +00: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:
parent
7c9095ea1d
commit
7630f1b52e
1 changed files with 4 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue