Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use a loop instead of recursion when processing a regex group
It can blow up the stack if too many characters are inside the group.
  • Loading branch information
ahmadsherif committed Feb 25, 2016
1 parent 3c0dba8 commit 680c9c8
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions core/regexp.rb
Expand Up @@ -456,13 +456,8 @@ def process_group_options
end

def process_until_group_finished
if @source[@index].chr == ")"
@index += 1
return
else
push_current_character!
process_until_group_finished
end
push_current_character! until @source[@index].chr == ")"
@index += 1
end

def push_current_character!
Expand Down

0 comments on commit 680c9c8

Please sign in to comment.