summaryrefslogtreecommitdiff
path: root/boost/regex/v4/perl_matcher_recursive.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2017-09-13 11:08:07 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2017-09-13 11:09:00 +0900
commitb5c87084afaef42b2d058f68091be31988a6a874 (patch)
treeadef9a65870a41181687e11d57fdf98e7629de3c /boost/regex/v4/perl_matcher_recursive.hpp
parent34bd32e225e2a8a94104489b31c42e5801cc1f4a (diff)
downloadboost-b5c87084afaef42b2d058f68091be31988a6a874.tar.gz
boost-b5c87084afaef42b2d058f68091be31988a6a874.tar.bz2
boost-b5c87084afaef42b2d058f68091be31988a6a874.zip
Imported Upstream version 1.64.0upstream/1.64.0
Change-Id: Id9212edd016dd55f21172c427aa7894d1d24148b Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/regex/v4/perl_matcher_recursive.hpp')
-rw-r--r--boost/regex/v4/perl_matcher_recursive.hpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/boost/regex/v4/perl_matcher_recursive.hpp b/boost/regex/v4/perl_matcher_recursive.hpp
index 33b9158193..8eb23abfdc 100644
--- a/boost/regex/v4/perl_matcher_recursive.hpp
+++ b/boost/regex/v4/perl_matcher_recursive.hpp
@@ -900,10 +900,27 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_recursion()
{
recursion_stack.reserve(50);
}
+ //
+ // See if we've seen this recursion before at this location, if we have then
+ // we need to prevent infinite recursion:
+ //
+ for(typename std::vector<recursion_info<results_type> >::reverse_iterator i = recursion_stack.rbegin(); i != recursion_stack.rend(); ++i)
+ {
+ if(i->idx == static_cast<const re_brace*>(static_cast<const re_jump*>(pstate)->alt.p)->index)
+ {
+ if(i->location_of_start == position)
+ return false;
+ break;
+ }
+ }
+ //
+ // Now get on with it:
+ //
recursion_stack.push_back(recursion_info<results_type>());
recursion_stack.back().preturn_address = pstate->next.p;
recursion_stack.back().results = *m_presult;
recursion_stack.back().repeater_stack = next_count;
+ recursion_stack.back().location_of_start = position;
pstate = static_cast<const re_jump*>(pstate)->alt.p;
recursion_stack.back().idx = static_cast<const re_brace*>(pstate)->index;
@@ -979,6 +996,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_match()
recursion_stack.push_back(recursion_info<results_type>());
recursion_stack.back().preturn_address = saved_state;
recursion_stack.back().results = *m_presult;
+ recursion_stack.back().location_of_start = position;
return false;
}
return true;