Skip to content

Commit

Permalink
Fix panic if Metadata is nil
Browse files Browse the repository at this point in the history
Metadata is nil will cause panic
  • Loading branch information
jokemanfire committed Oct 16, 2024
1 parent 956e121 commit 94a6e23
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/crictl/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ func getSandboxesList(sandboxesList []*pb.PodSandbox, opts *listOptions) []*pb.P
filtered := []*pb.PodSandbox{}
for _, p := range sandboxesList {
// Filter by pod name/namespace regular expressions.
if matchesRegex(opts.nameRegexp, p.Metadata.Name) &&
if p.Metadata != nil && matchesRegex(opts.nameRegexp, p.Metadata.Name) &&
matchesRegex(opts.podNamespaceRegexp, p.Metadata.Namespace) {
filtered = append(filtered, p)
}
Expand Down

0 comments on commit 94a6e23

Please sign in to comment.