diff mbox series

[FFmpeg-devel] avfilter/avfilter: move enable_str expression parsing into avfilter_init_dict()

Message ID 20210205112759.7338-1-onemda@gmail.com
State Accepted
Commit 6317d40d0813fa1e251730052de87fafb909b829
Headers show
Series [FFmpeg-devel] avfilter/avfilter: move enable_str expression parsing into avfilter_init_dict() | 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

Paul B Mahol Feb. 5, 2021, 11:27 a.m. UTC
This ensures that needed arrays are always allocated and properly initialized.

Previously if code would use only avfilter_init_dict() to set options for filters
it would not allocate arrays for timeline processing thus it would crash if
user supplied enable option for filter(s).

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavfilter/avfilter.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Paul B Mahol Feb. 5, 2021, 5:15 p.m. UTC | #1
Anybody have comments? This fixes crash.
Nicolas George Feb. 7, 2021, 4:33 p.m. UTC | #2
Paul B Mahol (12021-02-05):
> This ensures that needed arrays are always allocated and properly initialized.
> 
> Previously if code would use only avfilter_init_dict() to set options for filters
> it would not allocate arrays for timeline processing thus it would crash if
> user supplied enable option for filter(s).
> 
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavfilter/avfilter.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)

LGTM, thanks.

Regards,
diff mbox series

Patch

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 4c52d83842..d560655f42 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -875,11 +875,6 @@  static int process_options(AVFilterContext *ctx, AVDictionary **options,
         count++;
     }
 
-    if (ctx->enable_str) {
-        ret = set_enable_expr(ctx, ctx->enable_str);
-        if (ret < 0)
-            return ret;
-    }
     return count;
 }
 
@@ -930,6 +925,12 @@  int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options)
     else if (ctx->filter->init_dict)
         ret = ctx->filter->init_dict(ctx, options);
 
+    if (ctx->enable_str) {
+        ret = set_enable_expr(ctx, ctx->enable_str);
+        if (ret < 0)
+            return ret;
+    }
+
     return ret;
 }