avcodec/hevcdec: Check nb_sps
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 14 Jun 2017 23:28:28 +0000 (01:28 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 20 Jun 2017 00:05:09 +0000 (02:05 +0200)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit bc406744620710911de9157eafa3e61d0246566f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/hevc.c

index 0e849b8..0549133 100644 (file)
@@ -246,6 +246,8 @@ static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb)
         nb_sps = get_ue_golomb_long(gb);
     nb_sh = get_ue_golomb_long(gb);
 
+    if (nb_sps > sps->num_long_term_ref_pics_sps)
+        return AVERROR_INVALIDDATA;
     if (nb_sh + (uint64_t)nb_sps > FF_ARRAY_ELEMS(rps->poc))
         return AVERROR_INVALIDDATA;