Skip to content

Commit

Permalink
Fix malformed bounds for pattern regex
Browse files Browse the repository at this point in the history
  • Loading branch information
CodaFi committed Mar 1, 2018
1 parent 74c2868 commit 34ea75a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Sources/FileCheck/Pattern.swift
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ final class Pattern {
guard let r = try? NSRegularExpression(pattern: regExToMatch, options: [.anchorsMatchLines]) else {
return nil
}
let matchInfo = r.matches(in: buffer, range: NSRange(location: 0, length: buffer.utf8.count))
let distance = buffer.distance(from: buffer.startIndex, to: buffer.endIndex)
let matchInfo = r.matches(in: buffer, range: NSRange(location: 0, length: distance))

// Successful regex match.
guard let fullMatch = matchInfo.first else {
Expand Down

0 comments on commit 34ea75a

Please sign in to comment.