From 028fda02376c5d127d210c1e652472e44c572422 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Wed, 2 Aug 2017 19:36:31 -0700 Subject: [PATCH] Fix stream::read_size_hint calculation --- CHANGELOG.md | 1 + include/boost/beast/websocket/impl/stream.ipp | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) 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())); }