diff mbox series

[FFmpeg-devel,5/5] avcodec/hevc_refs: Check that nb_refs stays <= HEVC_MAX_REFS

Message ID 20230525214019.29048-5-michael@niedermayer.cc
State Accepted
Commit 6f2cf88771bd8c3986b0c8b6404eabc5b37d8a6e
Headers show
Series [FFmpeg-devel,1/5] avformat/mov: We do not support creation times of 300 billion years ago | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer May 25, 2023, 9:40 p.m. UTC
Fixes: 58528/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5834725318328320
Fixes: index 16 out of bounds for type 'int [16]'

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/hevc_refs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index e9be02c489..0716e1a597 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -353,7 +353,7 @@  int ff_hevc_slice_rpl(HEVCContext *s)
                 }
             }
             // Construct RefPicList0, RefPicList1 (8-8, 8-10)
-            if (s->ps.pps->pps_curr_pic_ref_enabled_flag) {
+            if (s->ps.pps->pps_curr_pic_ref_enabled_flag && rpl_tmp.nb_refs < HEVC_MAX_REFS) {
                 rpl_tmp.list[rpl_tmp.nb_refs]           = s->ref->poc;
                 rpl_tmp.ref[rpl_tmp.nb_refs]            = s->ref;
                 rpl_tmp.isLongTerm[rpl_tmp.nb_refs]     = 1;