Message ID | AM7PR03MB6660950FBA032B1CB4D7A7638FD99@AM7PR03MB6660.eurprd03.prod.outlook.com |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel,v2,01/14] avfilter/vsrc_testsrc: Deduplicate AVClasses | expand |
Context | Check | Description |
---|---|---|
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
andriy/make_ppc | success | Make finished |
andriy/make_fate_ppc | success | Make fate finished |
Andreas Rheinhardt (12021-09-14): > The documentation for filter arguments states that short options must > precede long options (i.e. those of the form key=value). Yet if > process_options() encounters arguments not abiding by this, it simply > treats short options after a long option as if it were parsing short > options for the first time. In particular, it overwrites options already > set earlier, possibly via other short options. This is not how it is > intended (as a comment in the code indicates). > > This commit modifies the code to reject further shorthand options > after a long option has been encountered. After all, avfilter_init_str() > errors out upon unrecognized options, so it is intended to be picky. > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> > --- > libavfilter/avfilter.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) Since you have a good reason to use a pointer instead of a integer boolean, then ok. Regards,
diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index cc499fd5ed..165ab1f44a 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -814,6 +814,7 @@ static int process_options(AVFilterContext *ctx, AVDictionary **options, const AVOption *o = NULL; int ret; char *av_uninit(parsed_key), *av_uninit(value); + const AVClass *priv = ctx->filter->priv_class; const char *key; int offset= -1; @@ -824,8 +825,7 @@ static int process_options(AVFilterContext *ctx, AVDictionary **options, const char *shorthand = NULL; int flags = AV_DICT_DONT_STRDUP_VAL; - o = av_opt_next(ctx->priv, o); - if (o) { + if (priv && (o = av_opt_next(ctx->priv, o))) { if (o->type == AV_OPT_TYPE_CONST || o->offset == offset) continue; offset = o->offset; @@ -848,7 +848,7 @@ static int process_options(AVFilterContext *ctx, AVDictionary **options, if (parsed_key) { key = parsed_key; flags |= AV_DICT_DONT_STRDUP_KEY; - while ((o = av_opt_next(ctx->priv, o))); /* discard all remaining shorthand */ + priv = NULL; /* reject all remaining shorthand */ } else { key = shorthand; }
The documentation for filter arguments states that short options must precede long options (i.e. those of the form key=value). Yet if process_options() encounters arguments not abiding by this, it simply treats short options after a long option as if it were parsing short options for the first time. In particular, it overwrites options already set earlier, possibly via other short options. This is not how it is intended (as a comment in the code indicates). This commit modifies the code to reject further shorthand options after a long option has been encountered. After all, avfilter_init_str() errors out upon unrecognized options, so it is intended to be picky. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavfilter/avfilter.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)