mirror of
https://github.com/boostorg/regex.git
synced 2025-07-16 13:52:17 +02:00
Fix potential overflow in max_state_count calculation.
Fixes: https://svn.boost.org/trac10/ticket/13036.
This commit is contained in:
@ -113,6 +113,11 @@ void perl_matcher<BidiIterator, Allocator, traits>::estimate_max_state_count(std
|
||||
std::ptrdiff_t states = re.size();
|
||||
if(states == 0)
|
||||
states = 1;
|
||||
if ((std::numeric_limits<std::ptrdiff_t>::max)() / states < states)
|
||||
{
|
||||
max_state_count = (std::min)((std::ptrdiff_t)BOOST_REGEX_MAX_STATE_COUNT, (std::numeric_limits<std::ptrdiff_t>::max)() - 2);
|
||||
return;
|
||||
}
|
||||
states *= states;
|
||||
if((std::numeric_limits<std::ptrdiff_t>::max)() / dist < states)
|
||||
{
|
||||
|
Reference in New Issue
Block a user