diff mbox series

[FFmpeg-devel,15/19] avfilter/vf_signature: Fix leak of inpads' names

Message ID 20200825140927.16433-15-andreas.rheinhardt@gmail.com
State Accepted
Commit 37838417b8045fa3a49acc55546c741d3f2ac602
Headers show
Series [FFmpeg-devel,01/19] avfilter/avfilter: Fix indentation
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Aug. 25, 2020, 2:09 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
It is not intended for these added lines to live very long: One can add
flags to AVFilter.flags_internal that indicate that this filter wants
the inpads/outpads' names be freed generically. This will allow to
remove most of the code for freeing in/outpads. These flags can also be
used to make ff_insert_in/outpad free the name itself upon error.

Furthermore, one can make ff_insert_pad() return AVERROR(ENOMEM) if the
name of the pad that is about to be inserted is NULL; this allows to
remove the checks for allocation failure from the callers.

 libavfilter/vf_signature.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Paul B Mahol Aug. 26, 2020, 8:25 p.m. UTC | #1
On 8/25/20, Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
> It is not intended for these added lines to live very long: One can add
> flags to AVFilter.flags_internal that indicate that this filter wants
> the inpads/outpads' names be freed generically. This will allow to
> remove most of the code for freeing in/outpads. These flags can also be
> used to make ff_insert_in/outpad free the name itself upon error.
>
> Furthermore, one can make ff_insert_pad() return AVERROR(ENOMEM) if the
> name of the pad that is about to be inserted is NULL; this allows to
> remove the checks for allocation failure from the callers.
>
>  libavfilter/vf_signature.c | 2 ++
>  1 file changed, 2 insertions(+)
>

LGTM

> diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c
> index 5ea55d5247..d09003746c 100644
> --- a/libavfilter/vf_signature.c
> +++ b/libavfilter/vf_signature.c
> @@ -730,6 +730,8 @@ static av_cold void uninit(AVFilterContext *ctx)
>          }
>          av_freep(&sic->streamcontexts);
>      }
> +    for (unsigned i = 0; i < ctx->nb_inputs; i++)
> +        av_freep(&ctx->input_pads[i].name);
>  }
>
>  static int config_output(AVFilterLink *outlink)
> --
> 2.20.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/libavfilter/vf_signature.c b/libavfilter/vf_signature.c
index 5ea55d5247..d09003746c 100644
--- a/libavfilter/vf_signature.c
+++ b/libavfilter/vf_signature.c
@@ -730,6 +730,8 @@  static av_cold void uninit(AVFilterContext *ctx)
         }
         av_freep(&sic->streamcontexts);
     }
+    for (unsigned i = 0; i < ctx->nb_inputs; i++)
+        av_freep(&ctx->input_pads[i].name);
 }
 
 static int config_output(AVFilterLink *outlink)