diff --git a/deflate.c b/deflate.c index 03459806..a578b1ae 100644 --- a/deflate.c +++ b/deflate.c @@ -279,6 +279,8 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, if (windowBits < 0) { /* suppress zlib wrapper */ wrap = 0; + if (windowBits < -15) + return Z_STREAM_ERROR; windowBits = -windowBits; } #ifdef GZIP diff --git a/inflate.c b/inflate.c index 2a3c4fe9..8acbef44 100644 --- a/inflate.c +++ b/inflate.c @@ -168,6 +168,8 @@ int windowBits; /* extract wrap request from windowBits parameter */ if (windowBits < 0) { + if (windowBits < -15) + return Z_STREAM_ERROR; wrap = 0; windowBits = -windowBits; }