Skip to content

Commit caa082e

Browse files
authored
Merge pull request #598 from rctcwyvrn/thanks-fuzzer
Backreferences do not guarantee forward progress
2 parents ceecaaa + a99b333 commit caa082e

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

Sources/_StringProcessing/ByteCodeGen.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,8 @@ extension DSLTree.Node {
10111011
case .atom(let atom):
10121012
switch atom {
10131013
case .changeMatchingOptions, .assertion: return false
1014+
// Captures may be nil so backreferences may be zero length matches
1015+
case .backreference: return false
10141016
default: return true
10151017
}
10161018
case .trivia, .empty:

Tests/RegexTests/MatchTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2554,4 +2554,8 @@ extension RegexTests {
25542554
expectProgram(for: "a{\(maxStorable-1),\(maxStorable*2)}", doesNotContain: [.quantify])
25552555
expectProgram(for: "a{\(maxStorable),\(maxStorable*2+1)}", doesNotContain: [.quantify])
25562556
}
2557+
2558+
func testFuzzerArtifacts() throws {
2559+
expectCompletion(regex: #"(b?)\1*"#, in: "a")
2560+
}
25572561
}

0 commit comments

Comments
 (0)