diff --git a/include/boost/regex/v4/basic_regex_parser.hpp b/include/boost/regex/v4/basic_regex_parser.hpp index aefabacb..0071a8ce 100644 --- a/include/boost/regex/v4/basic_regex_parser.hpp +++ b/include/boost/regex/v4/basic_regex_parser.hpp @@ -543,7 +543,11 @@ bool basic_regex_parser::parse_open_paren() template bool basic_regex_parser::parse_basic_escape() { - ++m_position; + if(++m_position == m_end) + { + fail(regex_constants::error_paren, m_position - m_base); + return false; + } bool result = true; switch(this->m_traits.escape_syntax_type(*m_position)) { diff --git a/test/regress/basic_tests.cpp b/test/regress/basic_tests.cpp index a1251f9b..25f00c24 100644 --- a/test/regress/basic_tests.cpp +++ b/test/regress/basic_tests.cpp @@ -61,6 +61,7 @@ void basic_tests() TEST_REGEX_SEARCH("\\(\\)", basic, "", match_default, make_array(0, 0, 0, 0, -2, -2)); TEST_INVALID_REGEX("\\(", basic); TEST_INVALID_REGEX("\\)", basic); + TEST_INVALID_REGEX("\\", basic); TEST_INVALID_REGEX("\\(aa", basic); TEST_INVALID_REGEX("aa\\)", basic); TEST_REGEX_SEARCH("()", basic, "()", match_default, make_array(0, 2, -2, -2));