From 76296fe2dd49c55d85f818005ea9bb6901807c79 Mon Sep 17 00:00:00 2001 From: Sven Almgren Date: Thu, 15 Mar 2012 16:15:41 +0100 Subject: [PATCH] Fixed broken conversion --- src/websocket_frame.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/websocket_frame.hpp b/src/websocket_frame.hpp index c4bc0d68b0..f41d7623b4 100644 --- a/src/websocket_frame.hpp +++ b/src/websocket_frame.hpp @@ -334,7 +334,11 @@ public: if (get_payload_size() == 0) { return close::status::NO_STATUS; } else if (get_payload_size() >= 2) { - uint16_t code = ntohs(reinterpret_cast(m_payload[1]) | reinterpret_cast(m_payload[0]) << 8); + char val[2] = { m_payload[0], m_payload[1] }; + uint16_t code; + + memcpy(&code, val, sizeof(code)); + code = ntohs(code); return close::status::value(code); } else {