Fix unaligned memory access on sparc (Thanks David Coppa)

This commit is contained in:
Michael Stapelberg 2011-04-28 21:44:29 +02:00
parent 2c6508a6a3
commit a149283964
1 changed files with 4 additions and 2 deletions

View File

@ -597,7 +597,8 @@ static void ipc_receive_message(EV_P_ struct ev_io *w, int revents) {
n -= strlen(I3_IPC_MAGIC); n -= strlen(I3_IPC_MAGIC);
/* The next 32 bit after the magic are the message size */ /* The next 32 bit after the magic are the message size */
uint32_t message_size = *((uint32_t*)message); uint32_t message_size;
memcpy(&message_size, (uint32_t*)message, sizeof(uint32_t));
message += sizeof(uint32_t); message += sizeof(uint32_t);
n -= sizeof(uint32_t); n -= sizeof(uint32_t);
@ -607,7 +608,8 @@ static void ipc_receive_message(EV_P_ struct ev_io *w, int revents) {
} }
/* The last 32 bits of the header are the message type */ /* The last 32 bits of the header are the message type */
uint32_t message_type = *((uint32_t*)message); uint32_t message_type;
memcpy(&message_type, (uint32_t*)message, sizeof(uint32_t));
message += sizeof(uint32_t); message += sizeof(uint32_t);
n -= sizeof(uint32_t); n -= sizeof(uint32_t);