-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
Description
Example pattern: (?:(?:0?)+?(?:a?)+?)?
Example Input: 0a
Should return 2 matches: index 0, length 2; index 2, length 0.
Actually returns: infinite matches: index 0, length 2; index 1, length 1; index 1, length 1...etc
Other information
The first match seems to work fine. The second match doesn't.
I did some digging--it may not be helpful, but figured I'd drop my notes in here. It appears that the Lazybranchmark operation pushes some data to regex stack assuming that a backtrace will happen. However, in this example the backtrace doesn't happen and the stack is left in a bad state with the extra item. So by the time Capturemark tries to build the match for Group 0 from the stack it has the wrong value and builds a match based on bad data. This causes our match to appear to move backwards in the string and get stuck with infinite matches.