From 8221544514e4a6568f2743994a6d2e72fafc094a Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Thu, 7 Dec 2023 16:23:42 -0600 Subject: [PATCH] chore: check if process is nil (#11090) * chore: check if process is nil We check if process is nil in the ports_supported file. Just matching that defensive check, not sure if it can be nil. --- agent/agentssh/portinspection_supported.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/agent/agentssh/portinspection_supported.go b/agent/agentssh/portinspection_supported.go index 45f59accc4..d45847bd6f 100644 --- a/agent/agentssh/portinspection_supported.go +++ b/agent/agentssh/portinspection_supported.go @@ -20,6 +20,12 @@ func getListeningPortProcessCmdline(port uint32) (string, error) { if len(tabs) == 0 { return "", nil } + + // Defensive check. + if tabs[0].Process == nil { + return "", nil + } + // The process name provided by go-netstat does not include the full command // line so grab that instead. pid := tabs[0].Process.Pid