             }
         } while status == COMPRESSION_STATUS_OK
         return crc32
+    }
+}
+
+private extension compression_stream {
+
+    mutating func prepare(for sourceData: Data?) -> Int {
+        guard let sourceData = sourceData else { return 0 }
+
+        self.src_size = sourceData.count
+        return sourceData.count
     }
 }
 

import Compression

extension Data {
    static func process(operation: compression_stream_operation, size: Int, bufferSize: Int, skipCRC32: Bool = false,
                        provider: Provider, consumer: Consumer) throws -> CRC32 {
        var crc32 = CRC32(0)

            if stream.src_size == 0 {
                do {
                    sourceData = try provider(position, Swift.min((size - position), bufferSize))
                    position += stream.prepare(for: sourceData)
                } catch { throw error }
            }
            if let sourceData = sourceData {
