avformat/hevc: Check num_negative_pics and num_positive_pics
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 12 May 2015 17:28:15 +0000 (19:28 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 12 May 2015 17:28:15 +0000 (19:28 +0200)
Fixes CID1238994

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/hevc.c

index 26c352c..16b06b4 100644 (file)
@@ -462,6 +462,9 @@ static int parse_rps(GetBitContext *gb, unsigned int rps_idx,
         unsigned int num_negative_pics = get_ue_golomb_long(gb);
         unsigned int num_positive_pics = get_ue_golomb_long(gb);
 
+        if ((num_positive_pics + (uint64_t)num_negative_pics) * 2 > get_bits_left(gb))
+            return AVERROR_INVALIDDATA;
+
         num_delta_pocs[rps_idx] = num_negative_pics + num_positive_pics;
 
         for (i = 0; i < num_negative_pics; i++) {