[FFmpeg-cvslog] lavc/utils: fix division by 0

Michael Niedermayer git at videolan.org
Thu May 10 18:18:12 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu May 10 17:36:49 2012 +0200| [8ea5df4fac57acf8a6e8cf575502ccd3dd776f57] | committer: Michael Niedermayer

lavc/utils: 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=8ea5df4fac57acf8a6e8cf575502ccd3dd776f57
---

 libavcodec/utils.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index c915de6..223dd3c 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -2070,8 +2070,8 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
     bps = av_get_exact_bits_per_sample(avctx->codec_id);
 
     /* codecs with an exact constant bits per sample */
-    if (bps > 0 && ch > 0 && frame_bytes > 0)
-        return (frame_bytes * 8) / (bps * ch);
+    if (bps > 0 && ch > 0 && frame_bytes > 0 && ch < 32768 && bps < 32768)
+        return (frame_bytes * 8LL) / (bps * ch);
     bps = avctx->bits_per_coded_sample;
 
     /* codecs with a fixed packet duration */



More information about the ffmpeg-cvslog mailing list