From: Russ Cox Date: Thu, 4 Mar 2010 01:30:29 +0000 (-0800) Subject: net: fix nil deref in testTimeout when Dial fails X-Git-Tag: weekly.2010-03-04~3 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=74b131c0abf977a4ee94aec42412b16f30f4549c;p=gostls13.git net: fix nil deref in testTimeout when Dial fails Pointed out by Scott Schwartz. Fixes #637. R=scotts CC=golang-dev https://golang.org/cl/225042 --- diff --git a/src/pkg/net/timeout_test.go b/src/pkg/net/timeout_test.go index f5ec5730f7..be36bcb41f 100644 --- a/src/pkg/net/timeout_test.go +++ b/src/pkg/net/timeout_test.go @@ -12,10 +12,11 @@ import ( func testTimeout(t *testing.T, network, addr string, readFrom bool) { fd, err := Dial(network, "", addr) - defer fd.Close() if err != nil { t.Errorf("dial %s %s failed: %v", network, addr, err) + return } + defer fd.Close() t0 := time.Nanoseconds() fd.SetReadTimeout(1e8) // 100ms var b [100]byte