h261: check the mtype index
authorLuca Barbato <lu_zero@gentoo.org>
Wed, 14 Aug 2013 14:57:21 +0000 (16:57 +0200)
committerLuca Barbato <lu_zero@gentoo.org>
Fri, 16 Aug 2013 12:56:49 +0000 (14:56 +0200)
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
libavcodec/h261dec.c

index 8872c6c..2832c62 100644 (file)
@@ -376,6 +376,11 @@ static int h261_decode_mb(H261Context *h)
 
     // Read mtype
     h->mtype = get_vlc2(&s->gb, h261_mtype_vlc.table, H261_MTYPE_VLC_BITS, 2);
+    if (h->mtype < 0 || h->mtype >= FF_ARRAY_ELEMS(ff_h261_mtype_map)) {
+        av_log(s->avctx, AV_LOG_ERROR, "Invalid mtype index %d\n",
+               h->mtype);
+        return SLICE_ERROR;
+    }
     h->mtype = ff_h261_mtype_map[h->mtype];
 
     // Read mquant