Mercurial > libavcodec.hg
changeset 7774:a570a1e80400 libavcodec
Prevent a division by 0 in the g726 decoder when the configured samplerate is 0.
patch by Laurent Aimar, fenrir via.ecp fr
author | diego |
---|---|
date | Tue, 02 Sep 2008 23:09:14 +0000 |
parents | 272a13ae94c0 |
children | 490ee89408c5 |
files | g726.c |
diffstat | 1 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/g726.c Tue Sep 02 17:15:28 2008 +0000 +++ b/g726.c Tue Sep 02 23:09:14 2008 +0000 @@ -301,7 +301,14 @@ 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");