From fe7d2d89840ea34c710183ae4a49bab481324ceb Mon Sep 17 00:00:00 2001 From: V2Ray Date: Tue, 6 Oct 2015 17:24:16 +0200 Subject: [PATCH] Recycle memory earlier in error case --- common/net/transport.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/net/transport.go b/common/net/transport.go index 374317e0b..01b8c754a 100644 --- a/common/net/transport.go +++ b/common/net/transport.go @@ -11,6 +11,9 @@ const ( func ReadFrom(reader io.Reader) ([]byte, error) { buffer := make([]byte, bufferSize) nBytes, err := reader.Read(buffer) + if nBytes == 0 { + buffer = nil + } return buffer[:nBytes], err }