diff --git a/common/crypto/auth.go b/common/crypto/auth.go index 52c84ebc..41aeae11 100644 --- a/common/crypto/auth.go +++ b/common/crypto/auth.go @@ -245,6 +245,8 @@ func (w *AuthenticationWriter) Write(b []byte) (int, error) { } func (w *AuthenticationWriter) WriteMultiBuffer(mb buf.MultiBuffer) (int, error) { + defer mb.Release() + const StartIndex = 17 * 1024 var totalBytes int for { diff --git a/proxy/shadowsocks/protocol.go b/proxy/shadowsocks/protocol.go index 993d7b62..daec7b61 100644 --- a/proxy/shadowsocks/protocol.go +++ b/proxy/shadowsocks/protocol.go @@ -385,6 +385,8 @@ type UDPWriter struct { } func (w *UDPWriter) Write(mb buf.MultiBuffer) error { + defer mb.Release() + for _, b := range mb { if err := w.writeInternal(b); err != nil { return err