diff --git a/amalgamate/crow_all.h b/amalgamate/crow_all.h index e4a98f71d..77fb663b2 100644 --- a/amalgamate/crow_all.h +++ b/amalgamate/crow_all.h @@ -9703,6 +9703,5 @@ namespace crow - diff --git a/include/crow/websocket.h b/include/crow/websocket.h index efcf834dc..d21d7e9cd 100644 --- a/include/crow/websocket.h +++ b/include/crow/websocket.h @@ -226,11 +226,13 @@ namespace crow case WebSocketReadState::Len16: { remaining_length_ = 0; - boost::asio::async_read(adaptor_.socket(), boost::asio::buffer(&remaining_length_, 2), - [this](const boost::system::error_code& ec, std::size_t bytes_transferred) + uint16_t remaining_length16_ = 0; + boost::asio::async_read(adaptor_.socket(), boost::asio::buffer(&remaining_length16_, 2), + [this,&remaining_length16_](const boost::system::error_code& ec, std::size_t bytes_transferred) { is_reading = false; - remaining_length_ = ntohs(*(uint16_t*)&remaining_length_); + remaining_length16_ = ntohs(remaining_length16_); + remaining_length_ = remaining_length16_; #ifdef CROW_ENABLE_DEBUG if (!ec && bytes_transferred != 2) {