Commit 74b131c0 authored by Russ Cox's avatar Russ Cox

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
parent f1550482
...@@ -12,10 +12,11 @@ import ( ...@@ -12,10 +12,11 @@ import (
func testTimeout(t *testing.T, network, addr string, readFrom bool) { func testTimeout(t *testing.T, network, addr string, readFrom bool) {
fd, err := Dial(network, "", addr) fd, err := Dial(network, "", addr)
defer fd.Close()
if err != nil { if err != nil {
t.Errorf("dial %s %s failed: %v", network, addr, err) t.Errorf("dial %s %s failed: %v", network, addr, err)
return
} }
defer fd.Close()
t0 := time.Nanoseconds() t0 := time.Nanoseconds()
fd.SetReadTimeout(1e8) // 100ms fd.SetReadTimeout(1e8) // 100ms
var b [100]byte var b [100]byte
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment