浏览代码

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 年之前
父节点
当前提交
952dc41929
共有 1 个文件被更改,包括 1 次插入1 次删除
  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)
 		}
 		}