diff mbox series

[FFmpeg-devel,2/5] avfilter/vf_dctdnoiz: Check threads

Message ID 20210606134757.18919-2-michael@niedermayer.cc
State Accepted
Headers show
Series [FFmpeg-devel,1/5] avfilter/vf_ciescope: Handle black as very dark neutral gray | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Michael Niedermayer June 6, 2021, 1:47 p.m. UTC
Fixes: floating point division by 0
Fixes: Ticket 8269

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavfilter/vf_dctdnoiz.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Anton Khirnov June 6, 2021, 2:52 p.m. UTC | #1
Quoting Michael Niedermayer (2021-06-06 15:47:54)
> Fixes: floating point division by 0
> Fixes: Ticket 8269
> 
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavfilter/vf_dctdnoiz.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libavfilter/vf_dctdnoiz.c b/libavfilter/vf_dctdnoiz.c
> index 63b1b29ea2..f09ab19c4d 100644
> --- a/libavfilter/vf_dctdnoiz.c
> +++ b/libavfilter/vf_dctdnoiz.c
> @@ -568,6 +568,9 @@ static int config_input(AVFilterLink *inlink)
>      av_log(ctx, AV_LOG_DEBUG, "threads: [max=%d hmax=%d user=%d] => %d\n",
>             MAX_THREADS, max_slice_h, ff_filter_get_nb_threads(ctx), s->nb_threads);
>  
> +    if (!s->nb_threads)
> +        return AVERROR(EINVAL);
> +

I presume the crash happens due to max_slice_h evaluating to 0. Wouldn't
it then make more sense to check max_slice_h directly? Or perhaps clip
it from below rather than failing?
Michael Niedermayer June 6, 2021, 7:22 p.m. UTC | #2
On Sun, Jun 06, 2021 at 04:52:13PM +0200, Anton Khirnov wrote:
> Quoting Michael Niedermayer (2021-06-06 15:47:54)
> > Fixes: floating point division by 0
> > Fixes: Ticket 8269
> > 
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  libavfilter/vf_dctdnoiz.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/libavfilter/vf_dctdnoiz.c b/libavfilter/vf_dctdnoiz.c
> > index 63b1b29ea2..f09ab19c4d 100644
> > --- a/libavfilter/vf_dctdnoiz.c
> > +++ b/libavfilter/vf_dctdnoiz.c
> > @@ -568,6 +568,9 @@ static int config_input(AVFilterLink *inlink)
> >      av_log(ctx, AV_LOG_DEBUG, "threads: [max=%d hmax=%d user=%d] => %d\n",
> >             MAX_THREADS, max_slice_h, ff_filter_get_nb_threads(ctx), s->nb_threads);
> >  
> > +    if (!s->nb_threads)
> > +        return AVERROR(EINVAL);
> > +
> 
> I presume the crash happens due to max_slice_h evaluating to 0. Wouldn't
> it then make more sense to check max_slice_h directly?

ok will change it to that


> Or perhaps clip
> it from below rather than failing?

the video was 1x1 pixel, maybe i lack imagination but i see no usecase
for applying dctdnoiz to a 1x1 video

thx

[...]
diff mbox series

Patch

diff --git a/libavfilter/vf_dctdnoiz.c b/libavfilter/vf_dctdnoiz.c
index 63b1b29ea2..f09ab19c4d 100644
--- a/libavfilter/vf_dctdnoiz.c
+++ b/libavfilter/vf_dctdnoiz.c
@@ -568,6 +568,9 @@  static int config_input(AVFilterLink *inlink)
     av_log(ctx, AV_LOG_DEBUG, "threads: [max=%d hmax=%d user=%d] => %d\n",
            MAX_THREADS, max_slice_h, ff_filter_get_nb_threads(ctx), s->nb_threads);
 
+    if (!s->nb_threads)
+        return AVERROR(EINVAL);
+
     s->p_linesize = linesize = FFALIGN(s->pr_width, 32);
     for (i = 0; i < 2; i++) {
         s->cbuf[i][0] = av_malloc_array(linesize * s->pr_height, sizeof(*s->cbuf[i][0]));