diff --git a/Sources/LZ77/Deflator/LZ77.DeflatorBuffers.Stream.swift b/Sources/LZ77/Deflator/LZ77.DeflatorBuffers.Stream.swift index 3dddf6cb..cfae46a1 100644 --- a/Sources/LZ77/Deflator/LZ77.DeflatorBuffers.Stream.swift +++ b/Sources/LZ77/Deflator/LZ77.DeflatorBuffers.Stream.swift @@ -436,7 +436,7 @@ extension LZ77.DeflatorBuffers.Stream } /// Emits a dynamic (type = 2) DEFLATE block. - mutating + private mutating func writeBlock(final:Bool = false) { let tree: diff --git a/Sources/LZ77/Deflator/LZ77.DeflatorBuffers.swift b/Sources/LZ77/Deflator/LZ77.DeflatorBuffers.swift index 9ab0cd0d..c5061cde 100644 --- a/Sources/LZ77/Deflator/LZ77.DeflatorBuffers.swift +++ b/Sources/LZ77/Deflator/LZ77.DeflatorBuffers.swift @@ -80,7 +80,8 @@ extension LZ77.DeflatorBuffers self.stream.compressBlocks(final: last) - guard case .zlib = self.format + guard last, + case .zlib = self.format else { return @@ -123,6 +124,12 @@ extension LZ77.DeflatorBuffers self.stream.compressBlocks(final: last) + guard last + else + { + return + } + let checksum:UInt32 = self.stream.input.checksum() let bytes:UInt32 = self.stream.input.integral.bytes self.stream.writeLittleEndianUInt32(checksum)