From 27782cad8dd3a2bda8514da8653f9de9d2224c3b Mon Sep 17 00:00:00 2001 From: Ben Arthur Date: Mon, 26 Jun 2023 17:55:16 -0400 Subject: [PATCH] inflating can also take streams larger than typemax(UInt32) --- src/decompression.jl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/decompression.jl b/src/decompression.jl index 8b647cf..0f54227 100644 --- a/src/decompression.jl +++ b/src/decompression.jl @@ -157,12 +157,15 @@ end function TranscodingStreams.process(codec::DecompressorCodec, input::Memory, output::Memory, error::Error) zstream = codec.zstream zstream.next_in = input.ptr - zstream.avail_in = input.size + + avail_in = min(input.size, typemax(UInt32)) + zstream.avail_in = avail_in zstream.next_out = output.ptr - zstream.avail_out = output.size + avail_out = min(output.size, typemax(UInt32)) + zstream.avail_out = avail_out code = inflate!(zstream, Z_NO_FLUSH) - Δin = Int(input.size - zstream.avail_in) - Δout = Int(output.size - zstream.avail_out) + Δin = Int(avail_in - zstream.avail_in) + Δout = Int(avail_out - zstream.avail_out) if code == Z_OK return Δin, Δout, :ok elseif code == Z_STREAM_END