From 3c2bd315dc4694396347037e2a39f0a5b49134c8 Mon Sep 17 00:00:00 2001 From: fangdingjun Date: Wed, 18 Jul 2018 09:31:16 +0800 Subject: [PATCH] fix crash issue on read after close --- tls.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tls.go b/tls.go index d256af3..900fafc 100644 --- a/tls.go +++ b/tls.go @@ -204,7 +204,9 @@ func (c *Conn) Read(buf []byte) (n int, err error) { if len(buf) == 0 { return 0, nil } - + if c.closed { + return 0, io.EOF + } //bufLen := len(buf) //cbuf := C.malloc(C.size_t(bufLen)) //defer C.free(cbuf) @@ -237,7 +239,9 @@ func (c *Conn) Write(buf []byte) (n int, err error) { if len(buf) == 0 { return 0, nil } - + if c.closed { + return 0, io.EOF + } //cbuf := C.CBytes(buf) //defer C.free(cbuf)