Avoid undefined negation behavior if windowBits is INT_MIN.

This commit is contained in:
Mark Adler 2022-10-06 16:33:42 -07:00
parent 138c93cffb
commit a9e14e8541
2 changed files with 4 additions and 0 deletions

View File

@ -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

View File

@ -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;
}