Provide correct arguments to inflateInit2.

windowBits of 16 means "decode gzip header" and "use window size
from zlib header". For some reason, this results in a window size
that is too small on OpenBSD. Instead, use maximum window size
explicitly, since there is no downside for doing so.
This commit is contained in:
whitequark 2017-12-17 18:41:08 +00:00
parent 13695be03a
commit 3d7e9f5e7b

View File

@ -36,8 +36,8 @@ std::string LoadStringFromGzip(const std::string &name) {
stream.zalloc = Z_NULL;
stream.zfree = Z_NULL;
stream.opaque = Z_NULL;
ssassert(inflateInit2(&stream, /*decode gzip header*/16) == Z_OK,
"Cannot start inflation");
const int windowBits = /*maximum window*/ 15 + /*decode gzip header*/16;
ssassert(inflateInit2(&stream, windowBits) == Z_OK, "Cannot start inflation");
// Extract length mod 2**32 from the gzip trailer.
std::string result;