[FFmpeg-devel] [PATCH] avfilter/xpsnr: avoid division by zero

Marton Balint cus at passwd.hu
Mon Jan 27 21:24:04 EET 2025



On Mon, 27 Jan 2025, Gyan Doshi wrote:

> The ref input may have its frame rate unset, which would then lead to
> SIGFPE.
>
> Related to #11428
> ---
> libavfilter/vf_xpsnr.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libavfilter/vf_xpsnr.c b/libavfilter/vf_xpsnr.c
> index 1b2c2a7c2c..8f86c188c5 100644
> --- a/libavfilter/vf_xpsnr.c
> +++ b/libavfilter/vf_xpsnr.c
> @@ -568,7 +568,8 @@ static int config_input_ref(AVFilterLink *inlink)
>     s->max_error_64 = (1 << s->depth) - 1; /* conventional limit */
>     s->max_error_64 *= s->max_error_64;
>
> -    s->frame_rate = il->frame_rate.num / il->frame_rate.den;
> +    // Avoid division by zero
> +    s->frame_rate = il->frame_rate.den ? (il->frame_rate.num / il->frame_rate.den) : 25;

I kind of prefer 0 instead of 25, as far as I see the code does not care, 
and 0 is better than an arbitrary value.

Thanks,
Marton

>
>     s->num_comps = (desc->nb_components > 3 ? 3 : desc->nb_components);
>
> -- 
> 2.46.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>


More information about the ffmpeg-devel mailing list