forked from boostorg/regex
* add failing test case * fix issue #232 Credit to OSS-Fuzz for finding the problematic test regexes and configurations.
This commit is contained in:
committed by
GitHub
parent
f0afa5d9b8
commit
0cbaa4ef17
@ -39,25 +39,34 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
# define BOOST_REGEX_DETAIL_THROW(ex) boost::throw_exception(ex)
|
||||
#else
|
||||
# define BOOST_REGEX_DETAIL_THROW(ex) throw ex
|
||||
#endif
|
||||
|
||||
namespace boost{
|
||||
namespace BOOST_REGEX_DETAIL_NS{
|
||||
|
||||
//
|
||||
// error checking API:
|
||||
//
|
||||
inline void verify_options(boost::regex_constants::syntax_option_type, match_flag_type mf)
|
||||
inline void verify_options(boost::regex_constants::syntax_option_type, match_flag_type mf)
|
||||
{
|
||||
auto is_perl = (mf & match_perl);
|
||||
auto is_posix = (mf & match_posix);
|
||||
|
||||
if (is_perl && is_posix)
|
||||
{
|
||||
BOOST_REGEX_DETAIL_THROW(std::logic_error("Usage Error: Can't mix Perl and POSIX matching rules"));
|
||||
}
|
||||
|
||||
//
|
||||
// can't mix match_extra with POSIX matching rules:
|
||||
//
|
||||
if ((mf & match_extra) && (mf & match_posix))
|
||||
if ((mf & match_extra) && is_posix)
|
||||
{
|
||||
std::logic_error msg("Usage Error: Can't mix regular expression captures with POSIX matching rules");
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
throw_exception(msg);
|
||||
#else
|
||||
throw msg;
|
||||
#endif
|
||||
BOOST_REGEX_DETAIL_THROW(std::logic_error("Usage Error: Can't mix regular expression captures with POSIX matching rules"));
|
||||
}
|
||||
}
|
||||
//
|
||||
|
@ -60,12 +60,7 @@ void perl_matcher<BidiIterator, Allocator, traits>::construct_init(const basic_r
|
||||
if(e.empty())
|
||||
{
|
||||
// precondition failure: e is not a valid regex.
|
||||
std::invalid_argument ex("Invalid regular expression object");
|
||||
#ifndef BOOST_REGEX_STANDALONE
|
||||
boost::throw_exception(ex);
|
||||
#else
|
||||
throw e;
|
||||
#endif
|
||||
BOOST_REGEX_DETAIL_THROW(std::invalid_argument("Invalid regular expression object"));
|
||||
}
|
||||
pstate = 0;
|
||||
m_match_flags = f;
|
||||
@ -98,7 +93,11 @@ void perl_matcher<BidiIterator, Allocator, traits>::construct_init(const basic_r
|
||||
match_any_mask = static_cast<unsigned char>((f & match_not_dot_newline) ? BOOST_REGEX_DETAIL_NS::test_not_newline : BOOST_REGEX_DETAIL_NS::test_newline);
|
||||
// Disable match_any if requested in the state machine:
|
||||
if(e.get_data().m_disable_match_any)
|
||||
{
|
||||
if (m_match_flags & match_posix)
|
||||
BOOST_REGEX_DETAIL_THROW(std::logic_error("Invalid regex for POSIX-style matching"));
|
||||
m_match_flags &= regex_constants::match_not_any;
|
||||
}
|
||||
}
|
||||
#ifdef BOOST_REGEX_MSVC
|
||||
# pragma warning(pop)
|
||||
|
Reference in New Issue
Block a user