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) {