Skip to content

Commit 1e7def4

Browse files
committed
fix body_limit application in parser
1 parent 0959b4f commit 1e7def4

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

src/parser.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,14 @@ prepare() ->
778778
{
779779
BOOST_ASSERT(
780780
h_.md.payload == payload::to_eof);
781-
n = clamp(body_limit_remain() + 1, n);
781+
// No more messages can be pipelined, so
782+
// limit the output buffer to the remaining
783+
// body limit plus one byte to detect
784+
// exhaustion.
785+
std::uint64_t r = body_limit_remain();
786+
if(r != std::uint64_t(-1))
787+
r += 1;
788+
n = clamp(r, n);
782789
}
783790

784791
nprepare_ = n;
@@ -803,7 +810,14 @@ prepare() ->
803810
{
804811
BOOST_ASSERT(
805812
h_.md.payload == payload::to_eof);
806-
n = clamp(body_limit_remain() + 1, n);
813+
// No more messages can be pipelined, so
814+
// limit the output buffer to the remaining
815+
// body limit plus one byte to detect
816+
// exhaustion.
817+
std::uint64_t r = body_limit_remain();
818+
if(r != std::uint64_t(-1))
819+
r += 1;
820+
n = clamp(r, n);
807821
n = clamp(n, eb_->max_size() - eb_->size());
808822
// fill capacity first to avoid an allocation
809823
std::size_t avail =

0 commit comments

Comments
 (0)