avformat/vqf: check number of channels before use.
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 7 May 2013 20:26:22 +0000 (22:26 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 7 May 2013 20:26:56 +0000 (22:26 +0200)
Fixes division by zero

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/vqf.c

index ed58828..1ce5359 100644 (file)
@@ -132,6 +132,11 @@ static int vqf_read_header(AVFormatContext *s)
             rate_flag           = AV_RB32(comm_chunk + 8);
             avio_skip(s->pb, len-12);
 
             rate_flag           = AV_RB32(comm_chunk + 8);
             avio_skip(s->pb, len-12);
 
+            if (st->codec->channels <= 0) {
+                av_log(s, AV_LOG_ERROR, "Invalid number of channels\n");
+                return AVERROR_INVALIDDATA;
+            }
+
             st->codec->bit_rate              = read_bitrate*1000;
             break;
         case MKTAG('D','S','I','Z'): // size of compressed data
             st->codec->bit_rate              = read_bitrate*1000;
             break;
         case MKTAG('D','S','I','Z'): // size of compressed data