From: Yann Collet Date: Fri, 9 Feb 2024 00:38:20 +0000 (-0800) Subject: fix fuzz issue 5131069967892480 X-Git-Tag: v1.5.6^2~67^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b0e8580dc7f71881361f3a6fe46841af9d70bedf;p=thirdparty%2Fzstd.git fix fuzz issue 5131069967892480 --- diff --git a/lib/compress/zstd_opt.c b/lib/compress/zstd_opt.c index 0449204dd..c2ec2a9ed 100644 --- a/lib/compress/zstd_opt.c +++ b/lib/compress/zstd_opt.c @@ -1216,6 +1216,7 @@ ZSTD_compressBlock_opt_generic(ZSTD_matchState_t* ms, if ( (optLevel >= 1) /* additional check only for higher modes */ && (prevMatch.litlen == 0) /* replace a match */ && (LL_INCPRICE(1) < 0) /* ll1 is cheaper than ll0 */ + && LIKELY(ip + cur < iend) ) { /* check next position, in case it would be cheaper */ int with1literal = prevMatch.price + LIT_PRICE(ip+cur) + LL_INCPRICE(1);