From 0621d95232560875fec53378f81ec8bf6d8993ac Mon Sep 17 00:00:00 2001 From: Michael Wolfendale <4563722+wolfendale@users.noreply.github.com> Date: Sun, 7 Jul 2024 15:54:30 +0100 Subject: [PATCH] fix: allocate buffers for incoming packets --- prudp_server.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/prudp_server.go b/prudp_server.go index 762b585..d734323 100644 --- a/prudp_server.go +++ b/prudp_server.go @@ -82,7 +82,8 @@ func (ps *PRUDPServer) listenDatagram(quit chan struct{}) { read, addr, err = ps.udpSocket.ReadFromUDP(buffer) if err == nil { - packetData := buffer[:read] + packetData := make([]byte, read) + copy(packetData, buffer[:read]) err = ps.handleSocketMessage(packetData, addr, nil) }