Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-5426] Data slices crash when converted to NSData #3836

Closed
CharlesJS opened this issue Jul 11, 2017 · 1 comment
Closed

[SR-5426] Data slices crash when converted to NSData #3836

CharlesJS opened this issue Jul 11, 2017 · 1 comment

Comments

@CharlesJS
Copy link

CharlesJS commented Jul 11, 2017

Previous ID SR-5426
Radar None
Original Reporter @CharlesJS
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 9 beta 3
Current trunk is currently failing to build.

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

md5: d5ab644c7bd1355aa0e4739968755585

is duplicated by:

  • SR-5425 Data slices do not convert to String properly

Issue Description:

If a Data slice is constructed using a partial range, and that slice is converted to an NSData, that NSData will crash the next time it is printed.

import Foundation

let data = "FooBar".data(using: .ascii)!
let slice = data[3...]

let nsSlice = slice as NSData
print(nsSlice) // terminated due to signal: SEGMENTATION FAULT (11)

If the slice is constructed using 3..<6 instead of 3... , then this works.

@belkadan
Copy link

belkadan commented Jul 11, 2017

@phausler fixed this recently.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants