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

fix a buffer leak in buffered reader

This commit is contained in:
Darien Raymond 2017-12-16 02:02:48 +01:00
parent c6b07a8fc1
commit 0959755d21
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -93,6 +93,9 @@ func (w *BufferedWriter) WriteMultiBuffer(b MultiBuffer) error {
defer b.Release()
for !b.IsEmpty() {
if w.buffer == nil {
w.buffer = New()
}
if err := w.buffer.AppendSupplier(ReadFrom(&b)); err != nil {
return err
}
@ -113,12 +116,8 @@ func (w *BufferedWriter) Flush() error {
return err
}
if w.buffered {
w.buffer = New()
} else {
w.buffer = nil
}
}
return nil
}