diff mbox series

[FFmpeg-devel,2/2] fftools/ffmpeg_filter: ensure that the inserted filters exist

Message ID 20240920133042.1211-2-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/2] configure: add missing filter dependencies to ffmpeg | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 fail Make failed
andriy/make_x86 fail Make failed

Commit Message

James Almer Sept. 20, 2024, 1:30 p.m. UTC
If not, report it as a bug. avfilter_graph_create_filter() will return ENOMEM if the
passed filter argument is NULL, which is misleading.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 fftools/ffmpeg_filter.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

James Almer Sept. 20, 2024, 1:31 p.m. UTC | #1
On 9/20/2024 10:30 AM, James Almer wrote:
> If not, report it as a bug. avfilter_graph_create_filter() will return ENOMEM if the
> passed filter argument is NULL, which is misleading.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>   fftools/ffmpeg_filter.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
> index 8b420e68ab..27d74341b5 100644
> --- a/fftools/ffmpeg_filter.c
> +++ b/fftools/ffmpeg_filter.c
> @@ -1444,11 +1444,15 @@ static int insert_filter(AVFilterContext **last_filter, int *pad_idx,
>                            const char *filter_name, const char *args)
>   {
>       AVFilterGraph *graph = (*last_filter)->graph;
> +    const AVFilter *filter = avfilter_get_by_name(filter_name)

Missing colon added locally...

>       AVFilterContext *ctx;
>       int ret;
>   
> +    if (!filter)
> +        return AVERROR_BUG;
> +
>       ret = avfilter_graph_create_filter(&ctx,
> -                                       avfilter_get_by_name(filter_name),
> +                                       filter,
>                                          filter_name, args, NULL, graph);
>       if (ret < 0)
>           return ret;
diff mbox series

Patch

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 8b420e68ab..27d74341b5 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1444,11 +1444,15 @@  static int insert_filter(AVFilterContext **last_filter, int *pad_idx,
                          const char *filter_name, const char *args)
 {
     AVFilterGraph *graph = (*last_filter)->graph;
+    const AVFilter *filter = avfilter_get_by_name(filter_name)
     AVFilterContext *ctx;
     int ret;
 
+    if (!filter)
+        return AVERROR_BUG;
+
     ret = avfilter_graph_create_filter(&ctx,
-                                       avfilter_get_by_name(filter_name),
+                                       filter,
                                        filter_name, args, NULL, graph);
     if (ret < 0)
         return ret;