[SCM] libav/experimental: Prevent a division by 0 in the g726 decoder when the configured samplerate is 0. patch by Laurent Aimar, fenrir via.ecp fr

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 16:29:17 UTC 2013


The following commit has been merged in the experimental branch:
commit bd10f6e1492492b0dfddc7dd8773e782ccea6daf
Author: Laurent Aimar <fenrir at via.ecp.fr>
Date:   Tue Sep 2 23:09:14 2008 +0000

    Prevent a division by 0 in the g726 decoder when the configured samplerate is 0.
    patch by Laurent Aimar, fenrir via.ecp fr
    
    Originally committed as revision 15160 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavcodec/g726.c b/libavcodec/g726.c
index 463d993..a769c19 100644
--- a/libavcodec/g726.c
+++ b/libavcodec/g726.c
@@ -301,7 +301,14 @@ static int16_t g726_encode(G726Context* c, int16_t sig)
 static av_cold int g726_init(AVCodecContext * avctx)
 {
     G726Context* c = avctx->priv_data;
-    unsigned int index= (avctx->bit_rate + avctx->sample_rate/2) / avctx->sample_rate - 2;
+    unsigned int index;
+
+    if (avctx->sample_rate <= 0) {
+        av_log(avctx, AV_LOG_ERROR, "Samplerate is invalid\n");
+        return -1;
+    }
+
+    index = (avctx->bit_rate + avctx->sample_rate/2) / avctx->sample_rate - 2;
 
     if (avctx->bit_rate % avctx->sample_rate && avctx->codec->encode) {
         av_log(avctx, AV_LOG_ERROR, "Bitrate - Samplerate combination is invalid\n");

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list