From 94a6e23a0dfbc010db65802559ecc6903cefc688 Mon Sep 17 00:00:00 2001 From: jokemanfire Date: Wed, 16 Oct 2024 17:56:57 +0800 Subject: [PATCH] Fix panic if Metadata is nil Metadata is nil will cause panic --- cmd/crictl/sandbox.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/crictl/sandbox.go b/cmd/crictl/sandbox.go index 7bf2cadb78..f72f8604eb 100644 --- a/cmd/crictl/sandbox.go +++ b/cmd/crictl/sandbox.go @@ -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) }