[FFmpeg-devel] [PATCH 12/15] avcodec/me_cmp: Fix type check

Michael Niedermayer michael at niedermayer.cc
Fri Jul 5 03:21:53 EEST 2024


Fixes: CID1604375 Out-of-bounds read

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavcodec/me_cmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/me_cmp.c b/libavcodec/me_cmp.c
index 592ee760840..f3e2f2482ef 100644
--- a/libavcodec/me_cmp.c
+++ b/libavcodec/me_cmp.c
@@ -517,7 +517,7 @@ av_cold int ff_set_cmp(const MECmpContext *c, me_cmp_func *cmp, int type, int mp
             cmp[i] = zero_cmp;
         return 0;
     }
-    if (type > FF_ARRAY_ELEMS(cmp_func_list) ||
+    if (type >= FF_ARRAY_ELEMS(cmp_func_list) ||
         !cmp_func_list[type].available ||
         !mpvenc && cmp_func_list[type].mpv_only) {
         av_log(NULL, AV_LOG_ERROR,
-- 
2.45.2



More information about the ffmpeg-devel mailing list