avformat/mxfdec: check sample size more completely
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 27 Sep 2013 16:54:58 +0000 (18:54 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 27 Sep 2013 17:09:15 +0000 (19:09 +0200)
Fixes division by zero
Fixes Ticket2992

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

index e8ee741..e06673c 100644 (file)
@@ -2195,7 +2195,9 @@ static int mxf_set_audio_pts(MXFContext *mxf, AVCodecContext *codec, AVPacket *p
 {
     MXFTrack *track = mxf->fc->streams[pkt->stream_index]->priv_data;
     pkt->pts = track->sample_count;
-    if (codec->channels <= 0 || av_get_bits_per_sample(codec->codec_id) <= 0)
+    if (   codec->channels <= 0
+        || av_get_bits_per_sample(codec->codec_id) <= 0
+        || codec->channels * (int64_t)av_get_bits_per_sample(codec->codec_id) < 8)
         return AVERROR(EINVAL);
     track->sample_count += pkt->size / (codec->channels * (int64_t)av_get_bits_per_sample(codec->codec_id) / 8);
     return 0;