No undefined behaviour in parser

closes #2172
This commit is contained in:
Richard Hodges
2021-03-03 19:11:20 +01:00
parent 300dea93b2
commit 670f01f050
2 changed files with 12 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
* Extra logic error detection in http parser.
* Move Windows CI to Drone. * Move Windows CI to Drone.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@@ -82,7 +82,17 @@ basic_parser<isRequest>::
put(net::const_buffer buffer, put(net::const_buffer buffer,
error_code& ec) error_code& ec)
{ {
BOOST_ASSERT(state_ != state::complete); // If this goes off you have tried to parse more data after the parser
// has completed. A common cause of this is re-using a parser, which is
// not supported. If you need to re-use a parser, consider storing it
// in an optional. Then reset() and emplace() prior to parsing each new
// message.
BOOST_ASSERT(!is_done());
if (is_done())
{
ec = error::stale_parser;
return 0;
}
auto p = static_cast<char const*>(buffer.data()); auto p = static_cast<char const*>(buffer.data());
auto n = buffer.size(); auto n = buffer.size();
auto const p0 = p; auto const p0 = p;