[FFmpeg-devel] [PATCH] IFF: Check for invalid width and height in decoder

Stefano Sabatini stefano.sabatini-lala
Mon May 10 00:52:22 CEST 2010


On date Monday 2010-05-10 00:11:36 +0200, Sebastian Vater encoded:
> M?ns Rullg?rd a ?crit :
> > Sebastian Vater <cdgs.basty at googlemail.com> writes:
> >
> >   
> >> +    if ((avctx->width <= 0) || (avctx->height <= 0)) {
> >>     
> >
> > Too much () IMO.
> >   
> 
> Fixed. Better this way? ;)
> 
> Although I personally prefer the method with the extra (), find it
> myself a bit more readable.
> So if you don't hesistate, please apply the other one.
> 
> -- 
> 
> Best regards,
>                    :-) Basty/CDGS (-:
> 

> diff --git a/libavcodec/iff.c b/libavcodec/iff.c
> index c911811..037322d 100644
> --- a/libavcodec/iff.c
> +++ b/libavcodec/iff.c
> @@ -115,6 +113,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
>          return AVERROR_INVALIDDATA;
>      }
>  
> +    if (avctx->width <= 0 || avctx->height <= 0) {
> +        av_log(avctx, AV_LOG_ERROR, "width and height <= 0 not supported\n");
> +        return AVERROR_INVALIDDATA;

not supported -> invalid

looks more correct. Also many decoders use avcodec_check_dimensions(),
but that doesn't check for w|h == 0.

Regards.
-- 
FFmpeg = Fabulous Fast Multimedia Puritan Excellent Gymnast



More information about the ffmpeg-devel mailing list