Avoid undefined negation behavior if windowBits is INT_MIN.
diff --git a/deflate.c b/deflate.c index 0345980..a578b1a 100644 --- a/deflate.c +++ b/deflate.c
@@ -279,6 +279,8 @@ 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 2a3c4fe..8acbef4 100644 --- a/inflate.c +++ b/inflate.c
@@ -168,6 +168,8 @@ /* extract wrap request from windowBits parameter */ if (windowBits < 0) { + if (windowBits < -15) + return Z_STREAM_ERROR; wrap = 0; windowBits = -windowBits; }