The readBuffer now checks if the whole packet has arrived before attempting to parse it.

This commit is contained in:
stiffly
2016-03-03 15:16:42 +01:00
parent ae3cab6cd1
commit a7bff92899
5 changed files with 21 additions and 5 deletions
+4 -1
View File
@@ -45,7 +45,10 @@ int UDPClient::readBuffer()
boost::asio::ip::udp::socket::message_peek, error);
int sizeOfPacket = 0;
memcpy(&sizeOfPacket, m_ReadBuffer, sizeof(int));
if (sizeOfPacket > m_Socket->available()) {
LOG_WARNING("UDPClient::readBuffer(): We haven't got the whole packet yet.");
return 0;
}
// if the buffer is to small increase the size of it
if (sizeOfPacket > m_BufferSize) {
delete[] m_ReadBuffer;