1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-06-10 01:40:44 +00:00

fix handling of empty buffer

This commit is contained in:
Darien Raymond 2018-04-09 16:48:25 +02:00
parent 61d9b04ca5
commit 4b45174650
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -248,14 +248,6 @@ func (w *AuthenticationWriter) writeStream(mb buf.MultiBuffer) error {
func (w *AuthenticationWriter) writePacket(mb buf.MultiBuffer) error {
defer mb.Release()
if mb.IsEmpty() {
b := buf.New()
defer b.Release()
eb, _ := w.seal(b)
return w.writer.WriteMultiBuffer(buf.NewMultiBufferValue(eb))
}
mb2Write := buf.NewMultiBufferCap(int32(len(mb)) + 1)
for !mb.IsEmpty() {
@ -276,6 +268,14 @@ func (w *AuthenticationWriter) writePacket(mb buf.MultiBuffer) error {
}
func (w *AuthenticationWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {
if mb.IsEmpty() {
b := buf.New()
defer b.Release()
eb, _ := w.seal(b)
return w.writer.WriteMultiBuffer(buf.NewMultiBufferValue(eb))
}
if w.transferType == protocol.TransferTypeStream {
return w.writeStream(mb)
}