Skip to content

Commit ca29f40

Browse files
committed
Revert "Fixes crash when DispatchData is created from an UnsafeBufferPointer<Uint8> with a nil address."
This reverts commit 86860b5 (fix should have been made in a branch)
1 parent 86860b5 commit ca29f40

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/swift/Data.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ public struct DispatchData : RandomAccessCollection {
5050
///
5151
/// - parameter bytes: A pointer to the memory. It will be copied.
5252
public init(bytes buffer: UnsafeBufferPointer<UInt8>) {
53-
let d = buffer.baseAddress == nil ? _swift_dispatch_data_empty()
54-
: dispatch_data_create(buffer.baseAddress!, buffer.count, nil,
55-
_dispatch_data_destructor_default())
53+
let d = dispatch_data_create(buffer.baseAddress!, buffer.count, nil, _dispatch_data_destructor_default())
5654
self.init(data: d)
5755
}
5856

@@ -62,8 +60,7 @@ public struct DispatchData : RandomAccessCollection {
6260
/// - parameter deallocator: Specifies the mechanism to free the indicated buffer.
6361
public init(bytesNoCopy bytes: UnsafeBufferPointer<UInt8>, deallocator: Deallocator = .free) {
6462
let (q, b) = deallocator._deallocator
65-
let d = bytes.baseAddress == nil ? _swift_dispatch_data_empty()
66-
: dispatch_data_create(bytes.baseAddress!, bytes.count, q?.__wrapped, b)
63+
let d = dispatch_data_create(bytes.baseAddress!, bytes.count, q?.__wrapped, b)
6764
self.init(data: d)
6865
}
6966

0 commit comments

Comments
 (0)