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.
This commit is contained in:
Steven Masley
2023-12-07 22:23:42 +00:00
committed by GitHub
parent dbbf8acc26
commit 8221544514
@@ -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