Fix bug in deflateBound() for level 0 and memLevel 9.

memLevel 9 would cause deflateBound() to assume the use of fixed
blocks, even if the compression level was 0, which forces stored
blocks. That could result in a bound less than the size of the
compressed data. Now level 0 always uses the stored blocks bound.
This commit is contained in:
Mark Adler 2022-12-15 09:07:13 -08:00
parent 76820e4107
commit e554695638
1 changed files with 2 additions and 1 deletions

View File

@ -752,7 +752,8 @@ uLong ZEXPORT deflateBound(strm, sourceLen)
/* if not default parameters, return one of the conservative bounds */
if (s->w_bits != 15 || s->hash_bits != 8 + 7)
return (s->w_bits <= s->hash_bits ? fixedlen : storelen) + wraplen;
return (s->w_bits <= s->hash_bits && s->level ? fixedlen : storelen) +
wraplen;
/* default settings: return tight bound for that case -- ~0.03% overhead
plus a small constant */