Explorar o código

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 %!s(int64=13) %!d(string=hai) anos
pai
achega
952dc41929
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  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() {
 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 {
 		if err := s.cmd.Process.Kill(); err != nil {
 			s.t.Error(err)
 			s.t.Error(err)
 		}
 		}