]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fix fuzz issue 5131069967892480 3902/head
authorYann Collet <yann.collet.73@gmail.com>
Fri, 9 Feb 2024 00:38:20 +0000 (16:38 -0800)
committerYann Collet <yann.collet.73@gmail.com>
Fri, 9 Feb 2024 00:38:20 +0000 (16:38 -0800)
lib/compress/zstd_opt.c

index 0449204ddd8f83e75760ff450bb6d718b1e0819b..c2ec2a9edcd33b49ad6d5e4fa7a3ce4099686770 100644 (file)
@@ -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);