diff --git a/CHANGELOG.md b/CHANGELOG.md index 16a4dc4f..2fc69f61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ WebSocket: * Refactor fail/clode code * Call do_fail from read_some * eof on accept returns error::closed +* Fix stream::read_size_hint calculation -------------------------------------------------------------------------------- diff --git a/include/boost/beast/websocket/impl/stream.ipp b/include/boost/beast/websocket/impl/stream.ipp index 3c119d9b..cc84d9fa 100644 --- a/include/boost/beast/websocket/impl/stream.ipp +++ b/include/boost/beast/websocket/impl/stream.ipp @@ -98,8 +98,11 @@ read_size_hint( buffer.max_size(), clamp(rd_.remain)); } } - return (std::min)(buffer.max_size(), (std::max)( - (std::max)(+tcp_frame_size, clamp(rd_.remain)), + return (std::min)( + buffer.max_size() - buffer.size(), + (std::max)((std::max)( + +tcp_frame_size, + clamp(rd_.remain)), buffer.capacity() - buffer.size())); }