net: fix possible nil pointer dereference on ReadFrom for windows

Fixes #10516.

Change-Id: Ia93f53d4e752bbcca6112bc75f6c3dbe30b90dac
Reviewed-on: https://go-review.googlesource.com/9192
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Mikio Hara 2015-04-21 13:50:01 +09:00
parent 0fc582e879
commit 0f6a3ba420
1 changed files with 5 additions and 1 deletions

View File

@ -481,8 +481,12 @@ func (fd *netFD) readFrom(buf []byte) (int, syscall.Sockaddr, error) {
o.rsan = int32(unsafe.Sizeof(*o.rsa))
return syscall.WSARecvFrom(o.fd.sysfd, &o.buf, 1, &o.qty, &o.flags, o.rsa, &o.rsan, &o.o, nil)
})
err = fd.eofError(n, err)
if err != nil {
return n, nil, err
}
sa, _ := o.rsa.Sockaddr()
return n, sa, fd.eofError(n, err)
return n, sa, err
}
func (fd *netFD) Write(buf []byte) (int, error) {