diff --git a/include/boost/regex/v5/pattern_except.hpp b/include/boost/regex/v5/pattern_except.hpp index 731aefb6f..3fbdca0a2 100644 --- a/include/boost/regex/v5/pattern_except.hpp +++ b/include/boost/regex/v5/pattern_except.hpp @@ -77,7 +77,8 @@ typedef regex_error bad_expression; namespace BOOST_REGEX_DETAIL_NS{ -inline void raise_runtime_error(const std::runtime_error& ex) +template +inline void raise_runtime_error(const E& ex) { #ifndef BOOST_REGEX_STANDALONE ::boost::throw_exception(ex); @@ -90,7 +91,7 @@ template void raise_error(const traits& t, regex_constants::error_type code) { (void)t; // warning suppression - std::runtime_error e(t.error_string(code)); + regex_error e(t.error_string(code), code, 0); ::boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(e); } diff --git a/include/boost/regex/v5/perl_matcher_non_recursive.hpp b/include/boost/regex/v5/perl_matcher_non_recursive.hpp index 1d2f0a53a..146eb3278 100644 --- a/include/boost/regex/v5/perl_matcher_non_recursive.hpp +++ b/include/boost/regex/v5/perl_matcher_non_recursive.hpp @@ -1353,6 +1353,7 @@ bool perl_matcher::unwind_repeater_counter(bool template bool perl_matcher::unwind_extra_block(bool) { + ++used_block_count; saved_extra_block* pmp = static_cast(m_backup_state); void* condemmed = m_stack_base; m_stack_base = pmp->base; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 04514302e..87bc16072 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -229,3 +229,5 @@ compile test_windows_defs_1.cpp ; compile test_windows_defs_2.cpp ; compile test_windows_defs_3.cpp ; compile test_windows_defs_4.cpp ; + +run issue153.cpp : : : msvc:-STACK:2097152 ; diff --git a/test/issue153.cpp b/test/issue153.cpp new file mode 100644 index 000000000..78726a0a0 --- /dev/null +++ b/test/issue153.cpp @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2021 +* John Maddock +* +* Use, modification and distribution are subject to the +* Boost Software License, Version 1.0. (See accompanying file +* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +* +*/ + +//#define BOOST_REGEX_MAX_BLOCKS 10 +// See https://github.com/boostorg/regex/issues/153 +#include +#include + +int main(int argc, char** argv) +{ + try + { + boost::regex e("\x28\x28\x1f\x28\x28\x28\x3f\x31\x29\x8\x29\xf3\x29\x21\x3d\x29\x3f\x3f\xe4\x2e\x2b\x1f\x3f\x7c\x28\x3f\x21\x28\x28\x61\x3f\x3f\x28\x2a\x53\x4b\x49\x50\x29\x4\x3f\x2e\x2a\x3f\x28\x3f\x31\x29\x30\x77\x29\x29\x29\x49\x29\x61\x63\xbe\x45\x30\xa1\x5c\xfe\x5\xd2\x26\xc0\xf5\x17\x6c\xd4\xc3\x72\xe9\xb6\x74"); + if (boost::regex_match("\xb9\x32\x7c\xbc\x2d\xa0\xb\x85\xf3\xcf\x93\xa7\xd0\x44\x7b\x21\x12\x93\x6a\x7b\x72\x6d\x1e\x69\x56\x31\x37\x30\x31\x34\x31\x31\x38\x33\x34\x36\x30\x34\x36\x39\x32\x33\x31\x37\x33\x31\x36\x38\x37\x33\x30\x33\x37\x31\x35\x38\x38\x34\x31\x30\x35\x37\x32\x37\xba\x3e\x4\xc7\x27\xe9\xae\xf2\x01\x84\x47\x1f\xdc\xc9\x4c\xe5\xbc\xcf\x17\x31\x37\x30\x31\x34\x31\x31\x38\x33\x34\x36\x30\x34\x36\x39\x32\x33\x31\x37\x33\x31\x36\x38\x37\x33\x30\x33\x37\x31\x35\x38\x38\x34\x31\x2c\xd6\xf5\x42\xe4\x13\x15\xde\x7e\xa1\x84\x5a\x32\xf5\x67\xd5\x13\x9a\xd1\xa6\x99\x18\x23\xf7\x5c\xf6\x40\x80\x9c\x79\xbe\x4a\xc2\x54\x94\x93\xa3\x50\x27\xaf\xd4\xc4\x3b\xd3\x49\x95\xe7\xa9\xa0\xa5\x14\x81\xd2\x9a\x77\x92\xa8\x81\xb0\xf4\x5b\xa8\x9c\x3e\x17\x3b\xbd\x86\x26\x9a\x57\x56\x12\xce\x8c\x4a\xca\x68\x86\x3d\xf5\xba\x75\xab\xb1\x76\x2d\xd\xf1\xc\x24\x5e\xc5\x6d\xc8\xdf\xa6\x18\x86\x5e\x56", e, boost::regex_constants::match_default | boost::regex_constants::match_partial)) + { + std::cout << "OK" << std::endl; + } + } + catch (const boost::regex_error& e) + { + assert(e.code() == boost::regex_constants::error_complexity); + std::cout << e.what() << std::endl; + } + return 0; +} +