Fix infinite loop in basic_parser

fix #452
This commit is contained in:
Vinnie Falco
2017-06-09 13:27:38 -07:00
parent 7b56f352b4
commit 04522398e0
3 changed files with 22 additions and 1 deletions

View File

@ -7,6 +7,7 @@ Version 51
* Use BOOST_STRINGIZE
* DynamicBuffer benchmarks
* Add construct, destroy to handler_alloc
* Fix infinite loop in basic_parser
API Changes:

View File

@ -171,7 +171,7 @@ loop:
case state::complete:
break;
}
if(p < p1 && eager())
if(p < p1 && ! is_done() && eager())
{
n = static_cast<std::size_t>(p1 - p);
goto loop;

View File

@ -984,6 +984,25 @@ public:
//--------------------------------------------------------------------------
// https://github.com/vinniefalco/Beast/issues/452
void
testRegression452()
{
error_code ec;
test_parser<true> p;
p.eager(true);
string_view s =
"GET / HTTP/1.1\r\n"
"\r\n"
"die!"
;
p.put(boost::asio::buffer(
s.data(), s.size()), ec);
pass();
}
//--------------------------------------------------------------------------
template<class Parser, class Pred>
void
bufgrind(string_view s, Pred&& pred)
@ -1067,6 +1086,7 @@ public:
testBody();
testSplit();
testRegression430();
testRegression452();
testBufGrind();
}
};