]> Cypherpunks repositories - gostls13.git/commitdiff
net: fix nil deref in testTimeout when Dial fails
authorRuss Cox <rsc@golang.org>
Thu, 4 Mar 2010 01:30:29 +0000 (17:30 -0800)
committerRuss Cox <rsc@golang.org>
Thu, 4 Mar 2010 01:30:29 +0000 (17:30 -0800)
Pointed out by Scott Schwartz.

Fixes #637.

R=scotts
CC=golang-dev
https://golang.org/cl/225042

src/pkg/net/timeout_test.go

index f5ec5730f76c4dd8327d472b7efa91fa475b8369..be36bcb41fac67a7fd8ac46136caace64565e396 100644 (file)
@@ -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