From 3c874bcf62ab4e453d745547512bd8a0835d3bcb Mon Sep 17 00:00:00 2001 From: irungentoo_trip Date: Tue, 21 Oct 2014 16:15:49 -0400 Subject: Fixed unaligned memory access. --- toxcore/Messenger.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'toxcore') diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 04d1a2f7..4841cbd9 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -2648,14 +2648,14 @@ uint32_t messenger_size(const Messenger *m) static uint8_t *z_state_save_subheader(uint8_t *data, uint32_t len, uint16_t type) { - uint32_t *data32 = (uint32_t *)data; - data32[0] = len; - data32[1] = (MESSENGER_STATE_COOKIE_TYPE << 16) | type; - data += sizeof(uint32_t) * 2; + memcpy(data, &len, sizeof(uint32_t)); + data += sizeof(uint32_t); + uint32_t temp = (MESSENGER_STATE_COOKIE_TYPE << 16) | type; + memcpy(data, &temp, sizeof(uint32_t)); + data += sizeof(uint32_t); return data; } - /* Save the messenger in data of size Messenger_size(). */ void messenger_save(const Messenger *m, uint8_t *data) { -- cgit v1.2.3