diff options
author | irungentoo_trip <irungentoo@gmail.com> | 2014-10-21 16:15:49 -0400 |
---|---|---|
committer | irungentoo_trip <irungentoo@gmail.com> | 2014-10-21 16:15:49 -0400 |
commit | 3c874bcf62ab4e453d745547512bd8a0835d3bcb (patch) | |
tree | b3adde09c585d4347e59df2630f4a83953962efa | |
parent | 5f26ee201c905a5267f500811b7a92d54bec008e (diff) |
Fixed unaligned memory access.
-rw-r--r-- | toxcore/Messenger.c | 10 |
1 files changed, 5 insertions, 5 deletions
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) | |||
2648 | 2648 | ||
2649 | static uint8_t *z_state_save_subheader(uint8_t *data, uint32_t len, uint16_t type) | 2649 | static uint8_t *z_state_save_subheader(uint8_t *data, uint32_t len, uint16_t type) |
2650 | { | 2650 | { |
2651 | uint32_t *data32 = (uint32_t *)data; | 2651 | memcpy(data, &len, sizeof(uint32_t)); |
2652 | data32[0] = len; | 2652 | data += sizeof(uint32_t); |
2653 | data32[1] = (MESSENGER_STATE_COOKIE_TYPE << 16) | type; | 2653 | uint32_t temp = (MESSENGER_STATE_COOKIE_TYPE << 16) | type; |
2654 | data += sizeof(uint32_t) * 2; | 2654 | memcpy(data, &temp, sizeof(uint32_t)); |
2655 | data += sizeof(uint32_t); | ||
2655 | return data; | 2656 | return data; |
2656 | } | 2657 | } |
2657 | 2658 | ||
2658 | |||
2659 | /* Save the messenger in data of size Messenger_size(). */ | 2659 | /* Save the messenger in data of size Messenger_size(). */ |
2660 | void messenger_save(const Messenger *m, uint8_t *data) | 2660 | void messenger_save(const Messenger *m, uint8_t *data) |
2661 | { | 2661 | { |