I have a problem using sf::Packets with sf::UdpSocket::Receive(). Every time I call the function it allocates more and more memory until it hits 0.5 GB and crashes. Here's a minimal example.
#include <SFML/Network.hpp>
int main() {
sf::UdpSocket socket;
socket.SetBlocking(false);
socket.Bind(54354);
sf::IpAddress client_ip;
unsigned short client_port;
sf::Packet packet;
while (true) {
socket.Receive(packet, client_ip, client_port);
}
}
Without Packets it works just as it should. It doesn't allocate more memory with every call.
char buffer[1024];
std::size_t received = 0;
while (true) {
socket.Receive(buffer, sizeof(buffer), received, client_ip, client_port);
}
Internally sf::UdpSocket::Receive() grows the size of sf::UdpSocket::myPendingPacket.Data every time.
Am I doing something wrong here or is this maybe a bug?
I'm using the latest SFML 2.0 snapshot.