Skip to content

Commit

Permalink
bug fix: Fix panic if c.Image is nil
Browse files Browse the repository at this point in the history
add judgement of c.Image

Signed-off-by: jokemanfire <[email protected]>
  • Loading branch information
jokemanfire committed Nov 19, 2024
1 parent a235aff commit adf924e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/crictl/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -1233,8 +1233,11 @@ func OutputContainers(runtimeClient internalapi.RuntimeService, imageClient inte
podNamespace := getPodNamespaceFromLabels(c.Labels)
if !opts.verbose {
id := c.Id
image := c.Image.Image
podID := c.PodSandboxId
var image string
if c.Image != nil {
image = c.Image.Image
}
if !opts.noTrunc {
id = getTruncatedID(id, "")
podID = getTruncatedID(podID, "")
Expand Down

0 comments on commit adf924e

Please sign in to comment.