Browse code

avcodec/hevc_refs: Check nb_refs in add_candidate_ref()

Fixes: runtime error: index 16 out of bounds for type 'int [16]'
Fixes: 2209/clusterfuzz-testcase-minimized-5012343912136704

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 1cb4ef526dd1e5f547d0354efb0831d07e967919)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

Michael Niedermayer authored on 2017/06/15 08:26:01
Showing 1 changed files
... ...
@@ -438,7 +438,7 @@ static int add_candidate_ref(HEVCContext *s, RefPicList *list,
438 438
 {
439 439
     HEVCFrame *ref = find_ref_idx(s, poc);
440 440
 
441
-    if (ref == s->ref)
441
+    if (ref == s->ref || list->nb_refs >= MAX_REFS)
442 442
         return AVERROR_INVALIDDATA;
443 443
 
444 444
     if (!ref) {