From: Nathan Moinvaziri Date: Mon, 6 Jul 2020 23:46:18 +0000 (-0700) Subject: Return proper exit code after flushing end block in deflate_quick when no available... X-Git-Tag: 1.9.9-b1~132 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=072f0bd93de683ba97d522421e98192caf6484d2;p=thirdparty%2Fzlib-ng.git Return proper exit code after flushing end block in deflate_quick when no available output. --- diff --git a/deflate_quick.c b/deflate_quick.c index 4c775300d..fb2e1382a 100644 --- a/deflate_quick.c +++ b/deflate_quick.c @@ -38,6 +38,8 @@ extern const ct_data static_dtree[D_CODES]; s->block_open = 0; \ s->block_start = s->strstart; \ flush_pending(s->strm); \ + if (s->strm->avail_out == 0) \ + return (last) ? finish_started : need_more; \ } \ } @@ -58,11 +60,11 @@ ZLIB_INTERNAL block_state deflate_quick(deflate_state *s, int flush) { QUICK_START_BLOCK(s, last); } - do { + for (;;) { if (UNLIKELY(s->pending + ((BIT_BUF_SIZE + 7) >> 3) >= s->pending_buf_size)) { flush_pending(s->strm); - if (s->strm->avail_out == 0 && flush != Z_FINISH) { - return need_more; + if (s->strm->avail_out == 0) { + return (last && s->strm->avail_in == 0) ? finish_started : need_more; } } @@ -105,14 +107,10 @@ ZLIB_INTERNAL block_state deflate_quick(deflate_state *s, int flush) { zng_tr_emit_lit(s, static_ltree, s->window[s->strstart]); s->strstart++; s->lookahead--; - } while (s->strm->avail_out != 0); + } s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1; - if (UNLIKELY(last)) { - if (s->strm->avail_out == 0) - return s->strm->avail_in == 0 ? finish_started : need_more; - QUICK_END_BLOCK(s, 1); return finish_done; }