diff --git a/CHANGELOG.md b/CHANGELOG.md index f757e900..55a85aa7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/include/beast/http/impl/basic_parser.ipp b/include/beast/http/impl/basic_parser.ipp index 343760a4..03754441 100644 --- a/include/beast/http/impl/basic_parser.ipp +++ b/include/beast/http/impl/basic_parser.ipp @@ -171,7 +171,7 @@ loop: case state::complete: break; } - if(p < p1 && eager()) + if(p < p1 && ! is_done() && eager()) { n = static_cast(p1 - p); goto loop; diff --git a/test/http/basic_parser.cpp b/test/http/basic_parser.cpp index 8a168675..fcd04e06 100644 --- a/test/http/basic_parser.cpp +++ b/test/http/basic_parser.cpp @@ -984,6 +984,25 @@ public: //-------------------------------------------------------------------------- + // https://github.com/vinniefalco/Beast/issues/452 + void + testRegression452() + { + error_code ec; + test_parser 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 void bufgrind(string_view s, Pred&& pred) @@ -1067,6 +1086,7 @@ public: testBody(); testSplit(); testRegression430(); + testRegression452(); testBufGrind(); } };