cafdec: Check duration before use.
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 11 Dec 2012 23:11:15 +0000 (00:11 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 12 Dec 2012 00:22:09 +0000 (01:22 +0100)
Fix division by 0

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

index 718942b..f12226a 100644 (file)
@@ -312,7 +312,7 @@ static int read_header(AVFormatContext *s)
     if (caf->bytes_per_packet > 0 && caf->frames_per_packet > 0) {
         if (caf->data_size > 0)
             st->nb_frames = (caf->data_size / caf->bytes_per_packet) * caf->frames_per_packet;
-    } else if (st->nb_index_entries) {
+    } else if (st->nb_index_entries && st->duration > 0) {
         st->codec->bit_rate = st->codec->sample_rate * caf->data_size * 8 /
                               st->duration;
     } else {