[FFmpeg-cvslog] cafdec: Check duration before use.

Michael Niedermayer git at videolan.org
Wed Dec 12 01:32:22 CET 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Dec 12 00:11:15 2012 +0100| [a202541f9b4da3e489716198dd3547ec7f73ef1d] | committer: Michael Niedermayer

cafdec: Check duration before use.

Fix division by 0

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

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a202541f9b4da3e489716198dd3547ec7f73ef1d
---

 libavformat/cafdec.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c
index 718942b..f12226a 100644
--- a/libavformat/cafdec.c
+++ b/libavformat/cafdec.c
@@ -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 {



More information about the ffmpeg-cvslog mailing list