mxf_set_audio_pts: fix division by 0
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 12 Dec 2012 10:35:31 +0000 (11:35 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 12 Dec 2012 10:35:47 +0000 (11:35 +0100)
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/mxfdec.c

index 0d773c5..e8ecbd9 100644 (file)
@@ -2057,6 +2057,8 @@ 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)
+        return AVERROR(EINVAL);
     track->sample_count += pkt->size / (codec->channels * av_get_bits_per_sample(codec->codec_id) / 8);
     return 0;
 }