Skip to content
Permalink
Browse files

Explicitly return a null pointer when payload length is zero

  • Loading branch information...
weichsel committed Apr 10, 2019
1 parent 8b884b3 commit 73a35c5a8babd83dd66ff8d4d1933220f638de6a
Showing with 1 addition and 2 deletions.
  1. +1 −2 Sources/ZIPFoundation/Data+Compression.swift
@@ -318,8 +318,7 @@ internal extension Data {
mutating func withUnsafeMutableBytes<T>(_ body: (UnsafeMutableRawBufferPointer) throws -> T) rethrows -> T {
let count = self.count
guard count > 0 else {
let alignment = MemoryLayout<UInt>.alignment
return try body(UnsafeMutableRawBufferPointer.allocate(byteCount: 0, alignment: alignment))
return try body(UnsafeMutableRawBufferPointer(start: nil, count: count))
}
return try withUnsafeMutableBytes { (pointer: UnsafeMutablePointer<UInt8>) throws -> T in
try body(UnsafeMutableRawBufferPointer(start: pointer, count: count))

0 comments on commit 73a35c5

Please sign in to comment.
You can’t perform that action at this time.