From 5869904c7f789580ace18f7e9084acbcd54a95be Mon Sep 17 00:00:00 2001 From: oyvindln Date: Sun, 28 Nov 2021 21:25:03 +0100 Subject: [PATCH] fix(inflate): Don't return HasMoreOutput if we are waiting for more input to read adler32 --- miniz_oxide/src/inflate/core.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/miniz_oxide/src/inflate/core.rs b/miniz_oxide/src/inflate/core.rs index 40e00765..8723760b 100644 --- a/miniz_oxide/src/inflate/core.rs +++ b/miniz_oxide/src/inflate/core.rs @@ -1648,7 +1648,13 @@ pub fn decompress( 0 }; - if status == TINFLStatus::NeedsMoreInput && out_buf.bytes_left() == 0 { + // Make sure HasMoreOutput overrides NeedsMoreInput if the output buffer is full. + // (Unless the missing input is the adler32 value in which case we don't need to write anything.) + // TODO: May want to see if we can do this in a better way. + if status == TINFLStatus::NeedsMoreInput + && out_buf.bytes_left() == 0 + && state != State::ReadAdler32 + { status = TINFLStatus::HasMoreOutput }