Skip to content

Commit a99b333

Browse files
committed
Backreferences do not guarantee forward progress
1 parent 1acca94 commit a99b333

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
@@ -1019,6 +1019,8 @@ extension DSLTree.Node {
10191019
case .atom(let atom):
10201020
switch atom {
10211021
case .changeMatchingOptions, .assertion: return false
1022+
// Captures may be nil so backreferences may be zero length matches
1023+
case .backreference: return false
10221024
default: return true
10231025
}
10241026
case .trivia, .empty:

Tests/RegexTests/MatchTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,4 +2549,8 @@ extension RegexTests {
25492549
expectProgram(for: "a{\(maxStorable-1),\(maxStorable*2)}", doesNotContain: [.quantify])
25502550
expectProgram(for: "a{\(maxStorable),\(maxStorable*2+1)}", doesNotContain: [.quantify])
25512551
}
2552+
2553+
func testFuzzerArtifacts() throws {
2554+
expectCompletion(regex: #"(b?)\1*"#, in: "a")
2555+
}
25522556
}

0 commit comments

Comments
 (0)