Make deflateBound() more conservative and handle Z_STREAM_END.
This commit is contained in:
parent
72d6aa2672
commit
a8c321be84
@ -846,13 +846,13 @@ uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) {
|
|||||||
storelen = sourceLen + (sourceLen >> 5) + (sourceLen >> 7) +
|
storelen = sourceLen + (sourceLen >> 5) + (sourceLen >> 7) +
|
||||||
(sourceLen >> 11) + 7;
|
(sourceLen >> 11) + 7;
|
||||||
|
|
||||||
/* if can't get parameters, return larger bound plus a zlib wrapper */
|
/* if can't get parameters, return larger bound plus a wrapper */
|
||||||
if (deflateStateCheck(strm))
|
if (deflateStateCheck(strm))
|
||||||
return (fixedlen > storelen ? fixedlen : storelen) + 6;
|
return (fixedlen > storelen ? fixedlen : storelen) + 18;
|
||||||
|
|
||||||
/* compute wrapper length */
|
/* compute wrapper length */
|
||||||
s = strm->state;
|
s = strm->state;
|
||||||
switch (s->wrap) {
|
switch (s->wrap < 0 ? -s->wrap : s->wrap) {
|
||||||
case 0: /* raw deflate */
|
case 0: /* raw deflate */
|
||||||
wraplen = 0;
|
wraplen = 0;
|
||||||
break;
|
break;
|
||||||
@ -882,7 +882,7 @@ uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) {
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default: /* for compiler happiness */
|
default: /* for compiler happiness */
|
||||||
wraplen = 6;
|
wraplen = 18;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if not default parameters, return one of the conservative bounds */
|
/* if not default parameters, return one of the conservative bounds */
|
||||||
|
Loading…
Reference in New Issue
Block a user