Still trying to fix "dereferencing type-punned pointer will break strict-aliasing rules"-warning.
This commit is contained in:
@@ -82,8 +82,9 @@ ReceiveBuffer::ScanPackets()
|
|||||||
// several packets may be received at once.
|
// several packets may be received at once.
|
||||||
if (recvBufUsed >= NET_HEADER_SIZE) {
|
if (recvBufUsed >= NET_HEADER_SIZE) {
|
||||||
// Read the size of the packet (first 4 bytes in network byte order).
|
// Read the size of the packet (first 4 bytes in network byte order).
|
||||||
const char *recvBufStart = &recvBuf[0];
|
uint32_t nativeVal;
|
||||||
size_t packetSize = ntohl(*((const uint32_t *)&recvBufStart));
|
memcpy(&nativeVal, &recvBuf[0], sizeof(uint32_t));
|
||||||
|
size_t packetSize = ntohl(nativeVal);
|
||||||
if (recvBufUsed >= packetSize + NET_HEADER_SIZE)
|
if (recvBufUsed >= packetSize + NET_HEADER_SIZE)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user