From 905172b0b21de4bbb768194d775d3b9647dbaf8c Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Thu, 12 Oct 2017 21:07:22 -0700 Subject: [PATCH] Fix deflateEnd() to not report an error at start of raw deflate. --- deflate.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/deflate.c b/deflate.c index 071ce679..c4bedfb8 100644 --- a/deflate.c +++ b/deflate.c @@ -462,7 +462,7 @@ int ZEXPORT deflateResetKeep(z_stream *strm) { #ifdef GZIP s->wrap == 2 ? GZIP_STATE : #endif - s->wrap ? INIT_STATE : BUSY_STATE; + INIT_STATE; #ifdef GZIP if (s->wrap == 2) @@ -756,6 +756,8 @@ int ZEXPORT deflate(z_stream *strm, int flush) { } /* Write the header */ + if (s->status == INIT_STATE && s->wrap == 0) + s->status = BUSY_STATE; if (s->status == INIT_STATE) { /* zlib header */ unsigned int header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; -- 2.47.2