Skip to content

Commit 9e21dcd

Browse files
committed
Backreferences do not guarantee forward progress
1 parent 4eb3233 commit 9e21dcd

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
@@ -1061,6 +1061,8 @@ extension DSLTree.Node {
10611061
case .atom(let atom):
10621062
switch atom {
10631063
case .changeMatchingOptions, .assertion: return false
1064+
// Captures may be nil so backreferences may be zero length matches
1065+
case .backreference: return false
10641066
default: return true
10651067
}
10661068
case .trivia, .empty:

Tests/RegexTests/MatchTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2534,4 +2534,8 @@ extension RegexTests {
25342534
expectCompletion(regex: #"(a{,4})*"#, in: "aa")
25352535
expectCompletion(regex: #"((|)+)*"#, in: "aa")
25362536
}
2537+
2538+
func testFuzzerArtifacts() throws {
2539+
expectCompletion(regex: #"(b?)\1*"#, in: "a")
2540+
}
25372541
}

0 commit comments

Comments
 (0)