Skip to content

Commit 34ea75a

Browse files
committed
Fix malformed bounds for pattern regex
1 parent 74c2868 commit 34ea75a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Sources/FileCheck/Pattern.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ final class Pattern {
355355
guard let r = try? NSRegularExpression(pattern: regExToMatch, options: [.anchorsMatchLines]) else {
356356
return nil
357357
}
358-
let matchInfo = r.matches(in: buffer, range: NSRange(location: 0, length: buffer.utf8.count))
358+
let distance = buffer.distance(from: buffer.startIndex, to: buffer.endIndex)
359+
let matchInfo = r.matches(in: buffer, range: NSRange(location: 0, length: distance))
359360

360361
// Successful regex match.
361362
guard let fullMatch = matchInfo.first else {

0 commit comments

Comments
 (0)