Hi, On Fri, Feb 10, 2012 at 1:44 PM, Paul B Mahol <[email protected]> wrote: > On 2/10/12, Ronald S. Bultje <[email protected]> wrote: >> On Fri, Feb 10, 2012 at 10:59 AM, Paul B Mahol <[email protected]> wrote: >>> On 2/10/12, Ronald S. Bultje <[email protected]> wrote: >>>> From: "Ronald S. Bultje" <[email protected]> >>>> >>>> Prevents a division by zero later on. >>>> --- >>>> libavcodec/tta.c | 3 +++ >>>> 1 files changed, 3 insertions(+), 0 deletions(-) >>>> >>>> diff --git a/libavcodec/tta.c b/libavcodec/tta.c >>>> index 49d5953..2fc1eb4 100644 >>>> --- a/libavcodec/tta.c >>>> +++ b/libavcodec/tta.c >>>> @@ -223,6 +223,9 @@ static av_cold int tta_decode_init(AVCodecContext * >>>> avctx) >>>> if (s->channels == 0) { >>>> av_log(s->avctx, AV_LOG_ERROR, "Invalid number of >>>> channels\n"); >>>> return AVERROR_INVALIDDATA; >>>> + } else if (avctx->sample_rate == 0) { >>>> + av_log(s->avctx, AV_LOG_ERROR, "Invalid samplerate\n"); >>>> + return AVERROR_INVALIDDATA; >>>> } >>>> >>>> switch(s->bps) { >>> >>> TTA Demuxer already checks for that, so this is I guess for other >>> containers. >>> >>> Such and similar checks (like the one above) just bloats code for >>> no good reason and should be fixed in nicer and more generic way. >> >> This can't be done more generally. The sample rate is read from the >> bitstream just five lines above and is used for a division just five >> lines below. How else would we check than in between these two? > > The sample rate is read in this case from extradata provided by demuxers. > Demuxers should already check for sane sample rate.
Are you suggesting that the demuxer parse the extradata? Ronald _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
