From: Alex Brainman Date: Mon, 26 Jul 2010 02:50:03 +0000 (+1000) Subject: net: fix crashing Read/Write when passed empty slice on windows X-Git-Tag: weekly.2010-07-29~41 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=4d87e8ab087fa0dfdc796219e739e4cff095cb73;p=gostls13.git net: fix crashing Read/Write when passed empty slice on windows Fixes #921. R=rsc CC=golang-dev https://golang.org/cl/1862043 --- diff --git a/src/pkg/net/fd_windows.go b/src/pkg/net/fd_windows.go index cdf446294a..c287d71539 100644 --- a/src/pkg/net/fd_windows.go +++ b/src/pkg/net/fd_windows.go @@ -198,7 +198,11 @@ func (fd *netFD) Close() os.Error { } func newWSABuf(p []byte) *syscall.WSABuf { - return &syscall.WSABuf{uint32(len(p)), (*byte)(unsafe.Pointer(&p[0]))} + var p0 *byte + if len(p) > 0 { + p0 = (*byte)(unsafe.Pointer(&p[0])) + } + return &syscall.WSABuf{uint32(len(p)), p0} } func (fd *netFD) Read(p []byte) (n int, err os.Error) {