]> Cypherpunks repositories - gostls13.git/commitdiff
net: fix crashing Read/Write when passed empty slice on windows
authorAlex Brainman <alex.brainman@gmail.com>
Mon, 26 Jul 2010 02:50:03 +0000 (12:50 +1000)
committerAlex Brainman <alex.brainman@gmail.com>
Mon, 26 Jul 2010 02:50:03 +0000 (12:50 +1000)
Fixes #921.

R=rsc
CC=golang-dev
https://golang.org/cl/1862043

src/pkg/net/fd_windows.go

index cdf446294a0fe57dd94bc0ac708acb5551d6f5f9..c287d71539c7d71c3cf7ee4c364df3fa9ef39682 100644 (file)
@@ -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) {