Skip to content

Commit

Permalink
<regex>: Limit capture groups (#4451)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanTLavavej committed Mar 8, 2024
1 parent 9c40b48 commit d6efe94
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions stl/inc/regex
Original file line number Diff line number Diff line change
Expand Up @@ -4153,9 +4153,13 @@ void _Parser<_FwdIt, _Elem, _RxTraits>::_CharacterClass() { // add bracket expre

template <class _FwdIt, class _Elem, class _RxTraits>
void _Parser<_FwdIt, _Elem, _RxTraits>::_Do_capture_group() { // add capture group
// if (_MAX_GRP <= ++_Grp_idx)
// _Error(regex_constants::error_complexity);
_Node_base* _Pos1 = _Nfa._Begin_capture_group(++_Grp_idx);
++_Grp_idx;

if (_Grp_idx >= 1000) { // hardcoded limit
_Xregex_error(regex_constants::error_stack);
}

_Node_base* _Pos1 = _Nfa._Begin_capture_group(_Grp_idx);
_Disjunction();
_Nfa._End_group(_Pos1);
_Finished_grps.resize(_Grp_idx + 1);
Expand Down

0 comments on commit d6efe94

Please sign in to comment.