From 1b70a57951b8bcbfb3c52232a74b09aadc0c9eac Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Thu, 21 Sep 2023 15:02:12 +0800 Subject: [PATCH] fix: tuicv5 panic in ReadFrom --- transport/tuic/v5/packet.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/transport/tuic/v5/packet.go b/transport/tuic/v5/packet.go index cd3ed12b..efbe0bb9 100644 --- a/transport/tuic/v5/packet.go +++ b/transport/tuic/v5/packet.go @@ -96,10 +96,10 @@ func (q *quicStreamPacketConn) SetWriteDeadline(t time.Time) error { } func (q *quicStreamPacketConn) ReadFrom(p []byte) (n int, addr net.Addr, err error) { - if q.inputConn != nil { + if inputConn := q.inputConn; inputConn != nil { // copy inputConn avoid be nil in for loop for { var packet Packet - packet, err = ReadPacket(q.inputConn) + packet, err = ReadPacket(inputConn) if err != nil { return } @@ -116,10 +116,10 @@ func (q *quicStreamPacketConn) ReadFrom(p []byte) (n int, addr net.Addr, err err } func (q *quicStreamPacketConn) WaitReadFrom() (data []byte, put func(), addr net.Addr, err error) { - if q.inputConn != nil { + if inputConn := q.inputConn; inputConn != nil { // copy inputConn avoid be nil in for loop for { var packet Packet - packet, err = ReadPacket(q.inputConn) + packet, err = ReadPacket(inputConn) if err != nil { return }