Fix read_size_helper usage:

read_size_helper can return zero if the buffer reaches
its maximum size, causing infinite loops in HTTP. The
function maybe_read_size_helper is provided to throw
an exception instead of returning a value for this case.
This commit is contained in:
Vinnie Falco
2017-07-20 08:12:19 -07:00
parent e4fdeecc3b
commit 78f4858e98
6 changed files with 47 additions and 21 deletions
+5 -10
View File
@@ -143,16 +143,11 @@ public:
BEAST_EXPECT(b.size() == 1);
}
{
flat_buffer b{10};
try
{
b.reserve(11);
fail("", __FILE__, __LINE__);
}
catch(std::length_error const&)
{
pass();
}
flat_buffer b{20};
ostream(b) << "12345";
b.consume(3);
ostream(b) << "67890123";
BEAST_EXPECT(to_string(b.data()) == "4567890123");
}
}