Browse Source

go.crypto/ssh/test: Fix distracting nil pointer dereference in a test.

If cgo is disabled (such as it appears to be on a subset of builders),
username() panics, and s.cmd is nil; let's not panic while recovering
from a different panic.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/8820043
David Symonds 12 years ago
parent
commit
952dc41929
1 changed files with 1 additions and 1 deletions
  1. 1 1
      ssh/test/test_unix_test.go

+ 1 - 1
ssh/test/test_unix_test.go

@@ -128,7 +128,7 @@ func (s *server) Dial(config *ssh.ClientConfig) *ssh.ClientConn {
 }
 
 func (s *server) Shutdown() {
-	if s.cmd.Process != nil {
+	if s.cmd != nil && s.cmd.Process != nil {
 		if err := s.cmd.Process.Kill(); err != nil {
 			s.t.Error(err)
 		}