1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-12 07:19:01 -05:00

remove references after content is written

This commit is contained in:
Darien Raymond 2018-08-31 22:56:17 +02:00
parent aefbc4c5de
commit 834dc4ab7c
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -33,7 +33,14 @@ func (w *BufferToBytesWriter) WriteMultiBuffer(mb MultiBuffer) error {
for _, b := range mb {
bs = append(bs, b.Bytes())
}
w.cache = bs[:0]
w.cache = bs
defer func() {
for idx := range w.cache {
w.cache[idx] = nil
}
w.cache = w.cache[:0]
}()
nb := net.Buffers(bs)