mirror of
https://github.com/golang/go.git
synced 2025-11-11 14:11:04 +00:00
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
This commit is contained in:
parent
f1550482fa
commit
74b131c0ab
1 changed files with 2 additions and 1 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue