Skip to content

[SR-13270] NSRegularExpression.numberOfMatches() with bad range doesn't fail #3976

@swift-ci

Description

@swift-ci
Previous ID SR-13270
Radar None
Original Reporter NPAssoc (JIRA User)
Type Bug
Environment

Raspian Linux Swift version 5.1.5-v0.1

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: 957478105529dab8d74d9fcb73634dae

Issue Description:

Given a regular expression like:

let testExp = try! NSRegularExpression(pattern: "(^| /) .", options: [])

The code:

let ss = "/Pairs Series/._Chair15.jpg"

let tRange = NSMakeRange(0, ss.count + 2)

let matches = testExp.numberOfMatches(in: ss, options: [], range: tRange)

fails on the Mac with: '...Range or index out of bounds'

but works under Raspian returning 0 matches.

Under Raspian, it should either fail or return 1 match.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions