From: Mark Adler Date: Sun, 2 Oct 2022 02:55:29 +0000 (-0700) Subject: Fix bug in block type selection when Z_FIXED used. X-Git-Tag: 2.1.0-beta1~83 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5393c21955013dc5f3724800e39f1a705ac3d289;p=thirdparty%2Fzlib-ng.git Fix bug in block type selection when Z_FIXED used. A fixed block could be chosen when a stored block was smaller. Now the smaller of the two is always chosen. --- diff --git a/trees.c b/trees.c index 111ead01f..5bb88389b 100644 --- a/trees.c +++ b/trees.c @@ -670,7 +670,7 @@ void Z_INTERNAL zng_tr_flush_block(deflate_state *s, char *buf, uint32_t stored_ opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len, s->sym_next / 3)); - if (static_lenb <= opt_lenb) + if (static_lenb <= opt_lenb || s->strategy == Z_FIXED) opt_lenb = static_lenb; } else { @@ -688,7 +688,7 @@ void Z_INTERNAL zng_tr_flush_block(deflate_state *s, char *buf, uint32_t stored_ */ zng_tr_stored_block(s, buf, stored_len, last); - } else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) { + } else if (static_lenb == opt_lenb) { zng_tr_emit_tree(s, STATIC_TREES, last); compress_block(s, (const ct_data *)static_ltree, (const ct_data *)static_dtree); cmpr_bits_add(s, s->static_len);