From b1bc0c83c707c2bad2f4f20d2cd0d8a4f8a744d7 Mon Sep 17 00:00:00 2001 From: Etienne Cimon Date: Mon, 4 Jan 2021 20:38:36 -0500 Subject: [PATCH] Update zlib.d Handle inputs left hanging at the middle of a block --- stream/vibe/stream/zlib.d | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stream/vibe/stream/zlib.d b/stream/vibe/stream/zlib.d index 38b78502dc..e0efb565d3 100644 --- a/stream/vibe/stream/zlib.d +++ b/stream/vibe/stream/zlib.d @@ -371,6 +371,13 @@ class ZlibInputStream : InputStream { m_in.read(m_inbuffer[0 .. clen]); m_zstream.next_in = &m_inbuffer[0]; m_zstream.avail_in = cast(uint)clen; + } else { + import core.stdc.string : memmove; + memmove(m_inbuffer.ptr, m_zstream.next_in, m_zstream.avail_in); + auto clen = min(m_inbuffer.length - m_zstream.avail_in, m_in.leastSize); + m_in.read(m_inbuffer.ptr[m_zstream.avail_in .. m_zstream.avail_in+clen]); + m_zstream.next_in = &m_inbuffer[0]; + m_zstream.avail_in += cast(uint)clen; } auto avins = m_zstream.avail_in; //logInfo("inflate %s -> %s (@%s in @%s)", m_zstream.avail_in, m_zstream.avail_out, m_ninflated, n_read);