Skip to content

[SR-6361] Data.withUnsafeMutableBytes() crash #4059

@swift-ci

Description

@swift-ci
Previous ID SR-6361
Radar None
Original Reporter sashabelonogov (JIRA User)
Type Bug
Status Closed
Resolution Done
Environment

macOS 10.12.6, Xcode 9.0, Swift 4.0

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee sashabelonogov (JIRA)
Priority Medium

md5: 30798dd20aad53ebbf352c04dbf2174d

Issue Description:

This example:

var data = Data(bytes: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])[4..<6]
        data.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer<UInt8>) in
            ptr.advanced(by: 1).pointee = 0xFF
        }

crashes with:

fatal error: UnsafeMutableRawBufferPointer with negative count

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