mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-08 07:58:40 +00:00
p2p/discover: copy buffer before sending read errors to unhandled
This commit is contained in:
parent
aaa2b66285
commit
9ee20fbf7f
1 changed files with 3 additions and 1 deletions
|
|
@ -555,8 +555,10 @@ func (t *UDPv4) readLoop(unhandled chan<- ReadPacket) {
|
|||
if err := t.handlePacket(from, buf[:nbytes]); err != nil && unhandled == nil {
|
||||
t.log.Debug("Bad discv4 packet", "addr", from, "err", err)
|
||||
} else if err != nil && unhandled != nil {
|
||||
packet := make([]byte, nbytes)
|
||||
copy(packet, buf[:nbytes])
|
||||
select {
|
||||
case unhandled <- ReadPacket{buf[:nbytes], from}:
|
||||
case unhandled <- ReadPacket{packet, from}:
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue