Skip to content

Commit

Permalink
fix tuicv5 panic in ReadFrom
Browse files Browse the repository at this point in the history
  • Loading branch information
wwqgtxx committed Sep 21, 2023
1 parent 4566a4d commit 2b6c42d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions transport/tuic/v5/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down

0 comments on commit 2b6c42d

Please sign in to comment.