diff options
author | Laurent Aimar | 2008-09-02 23:09:14 +0000 |
---|---|---|
committer | Diego Biurrun | 2008-09-02 23:09:14 +0000 |
commit | bd10f6e1492492b0dfddc7dd8773e782ccea6daf (patch) | |
tree | c40407b8022b8a72787f8bc02e14e06f971045df /libavcodec/g726.c | |
parent | d1c2156bc6e3fd723ba8fff02815a3cc2f8769b7 (diff) |
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
Diffstat (limited to 'libavcodec/g726.c')
-rw-r--r-- | libavcodec/g726.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libavcodec/g726.c b/libavcodec/g726.c index 463d993137..a769c19d23 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"); |