[FFmpeg-devel] [PATCH v2] avfilter/vf_scale: Cleanup some checks

Anton Khirnov anton at khirnov.net
Tue Jul 9 16:17:28 EEST 2024


Quoting Michael Niedermayer (2024-07-09 13:37:11)
> Fixes: CID1513722 Operands don't affect result
> 
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> ---
>  libavfilter/vf_scale.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
> index bf09196e10d..18e9393d6c1 100644
> --- a/libavfilter/vf_scale.c
> +++ b/libavfilter/vf_scale.c
> @@ -645,10 +645,8 @@ static int config_props(AVFilterLink *outlink)
>      if (ret < 0)
>          goto fail;
>  
> -    if (outlink->w > INT_MAX ||
> -        outlink->h > INT_MAX ||
> -        (outlink->h * inlink->w) > INT_MAX ||
> -        (outlink->w * inlink->h) > INT_MAX)
> +    if ((outlink->h * (int64_t)inlink->w) > INT32_MAX ||
> +        (outlink->w * (int64_t)inlink->h) > INT32_MAX)

This does not seems cleaner to me.

Also, this check overall seems fishy. Why is it here at all and not e.g.
in ff_scale_adjust_dimensions()? Why does it not call
av_image_check_size()? Why does it only print a warning and not do
anything else?

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list