Still trying to fix "dereferencing type-punned pointer will break strict-aliasing rules"-warning.

This commit is contained in:
lotodore
2012-11-27 23:11:50 +01:00
parent 7ef3cc25bd
commit b7f46d12e2
+3 -2
View File
@@ -82,8 +82,9 @@ ReceiveBuffer::ScanPackets()
// several packets may be received at once.
if (recvBufUsed >= NET_HEADER_SIZE) {
// Read the size of the packet (first 4 bytes in network byte order).
const char *recvBufStart = &recvBuf[0];
size_t packetSize = ntohl(*((const uint32_t *)&recvBufStart));
uint32_t nativeVal;
memcpy(&nativeVal, &recvBuf[0], sizeof(uint32_t));
size_t packetSize = ntohl(nativeVal);
if (recvBufUsed >= packetSize + NET_HEADER_SIZE)
{
try {