Skip to content

[SR-3509] Foundation CharacterSet Crash #4306

@swift-ci

Description

@swift-ci
Previous ID SR-3509
Radar None
Original Reporter bnut (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

xcodebuild -version Xcode 8.2 Build version 8C38

swift --version Apple Swift version 3.0.2 (swiftlang-800.0.63 clang-800.0.42.1) Target: x86_64-apple-macosx10.9

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

md5: b6a77aabb80a8d86278845247ab9a265

Issue Description:

The following code causes a crash in foundation at runtime:

var set = CharacterSet()
set.insert("\u{D7FF}") // no crash
set.insert("\u{D7FF}") // no crash
set.insert(charactersIn: "\u{D7FE}"..."\u{D7FF}") // crashes

According to the UnicodeScalar.init(_:UInt32) source, 0xD7FF is a valid character:

    //     * As a result of this definition, the set of Unicode scalar values
    //     consists of the ranges 0 to D7FF and E000 to 10FFFF, inclusive.

https://github.com/apple/swift/blob/2fe4254cb712fa101a220f95b6ade8f99f43dc74/stdlib/public/core/UnicodeScalar.swift#L97

I suspect there is an edge case where 0xD7FF is accidentally excluded.

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