From f4b7e9ee700a701837153f7fc7d7372c63a626d8 Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Mon, 8 Jul 2019 09:07:28 +0200 Subject: [PATCH] Fix undefined store in formatMessage --- src/WebSocketProtocol.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/WebSocketProtocol.h b/src/WebSocketProtocol.h index 3ffafd2..d3c4159 100644 --- a/src/WebSocketProtocol.h +++ b/src/WebSocketProtocol.h @@ -193,11 +193,13 @@ static inline size_t formatMessage(char *dst, const char *src, size_t length, Op } else if (reportedLength <= UINT16_MAX) { headerLength = 4; dst[1] = 126; - *((uint16_t *) &dst[2]) = cond_byte_swap(reportedLength); + uint16_t tmp = cond_byte_swap(reportedLength); + memcpy(&dst[2], &tmp, sizeof(uint16_t)); } else { headerLength = 10; dst[1] = 127; - *((uint64_t *) &dst[2]) = cond_byte_swap(reportedLength); + uint64_t tmp = cond_byte_swap(reportedLength); + memcpy(&dst[2], &tmp, sizeof(uint64_t)); } int flags = 0;