crypto/tls: don't block on Read of zero bytes
Fixes #7775
LGTM=rsc
R=agl, rsc
CC=golang-codereviews
https://golang.org/cl/88340043
diff --git a/src/pkg/crypto/tls/conn.go b/src/pkg/crypto/tls/conn.go
index 000b23c..550bc7f 100644
--- a/src/pkg/crypto/tls/conn.go
+++ b/src/pkg/crypto/tls/conn.go
@@ -884,6 +884,11 @@
if err = c.Handshake(); err != nil {
return
}
+ if len(b) == 0 {
+ // Put this after Handshake, in case people were calling
+ // Read(nil) for the side effect of the Handshake.
+ return
+ }
c.in.Lock()
defer c.in.Unlock()