diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2022-12-15 09:07:13 -0800 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2022-12-15 09:15:31 -0800 |
commit | e554695638228b846d49657f31eeff0ca4680e8a (patch) | |
tree | 8f01c7ef4e8c6f599922a38700165c8537fdcdbf | |
parent | 76820e4107f534231f1302351a7ea479e86d1dd4 (diff) | |
download | zlib-e554695638228b846d49657f31eeff0ca4680e8a.tar.gz zlib-e554695638228b846d49657f31eeff0ca4680e8a.tar.bz2 zlib-e554695638228b846d49657f31eeff0ca4680e8a.zip |
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.
-rw-r--r-- | deflate.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -752,7 +752,8 @@ uLong ZEXPORT deflateBound(strm, sourceLen) | |||
752 | 752 | ||
753 | /* if not default parameters, return one of the conservative bounds */ | 753 | /* if not default parameters, return one of the conservative bounds */ |
754 | if (s->w_bits != 15 || s->hash_bits != 8 + 7) | 754 | if (s->w_bits != 15 || s->hash_bits != 8 + 7) |
755 | return (s->w_bits <= s->hash_bits ? fixedlen : storelen) + wraplen; | 755 | return (s->w_bits <= s->hash_bits && s->level ? fixedlen : storelen) + |
756 | wraplen; | ||
756 | 757 | ||
757 | /* default settings: return tight bound for that case -- ~0.03% overhead | 758 | /* default settings: return tight bound for that case -- ~0.03% overhead |
758 | plus a small constant */ | 759 | plus a small constant */ |