mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-08 07:58:40 +00:00
p2p/discover: use bytes.Clone
This commit is contained in:
parent
9ee20fbf7f
commit
59787a1d80
1 changed files with 2 additions and 4 deletions
|
|
@ -555,10 +555,8 @@ 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{packet, from}:
|
||||
p := ReadPacket{bytes.Clone(buf[:nbytes]), from}
|
||||
case unhandled <- p:
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue