From: Nathan Moinvaziri Date: Fri, 6 Mar 2020 23:51:03 +0000 (-0800) Subject: Fixed compressBound calculation for quick deflate strategy. Worse case is 9 bits... X-Git-Tag: 1.9.9-b1~345 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7cf5afc5d59d25da12c8edf46344b799d7b6d22f;p=thirdparty%2Fzlib-ng.git Fixed compressBound calculation for quick deflate strategy. Worse case is 9 bits per literal plus the size of headers and footers for block and gzip format. Works out to the size of the input plus additional 13.67%. --- diff --git a/compress.c b/compress.c index 5adcf653c..3c29ddea1 100644 --- a/compress.c +++ b/compress.c @@ -75,5 +75,11 @@ int ZEXPORT PREFIX(compress)(unsigned char *dest, z_size_t *destLen, const unsig this function needs to be updated. */ z_size_t ZEXPORT PREFIX(compressBound)(z_size_t sourceLen) { +#ifdef X86_QUICK_STRATEGY + /* Quick deflate strategy worse case is 9 bits per literal, rounded to nearest byte, + plus the size of block & gzip headers and footers */ + return sourceLen + ((sourceLen + 13 + 7) >> 3) + 18; +#else return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + (sourceLen >> 25) + 13; +#endif }