Add bounds checking to ERR_MSG() macro, used by zError().

This commit is contained in:
Mark Adler 2023-12-07 06:38:10 -08:00
parent 643e17b749
commit 431a9b65ea
1 changed files with 1 additions and 1 deletions

View File

@ -56,7 +56,7 @@ typedef unsigned long ulg;
extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
/* (size given to avoid silly warnings with Visual C++) */
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
#define ERR_MSG(err) z_errmsg[(err) < -6 || (err) > 2 ? 9 : 2 - (err)]
#define ERR_RETURN(strm,err) \
return (strm->msg = ERR_MSG(err), (err))