diff mbox series

[FFmpeg-devel,04/10] avfilter/avfilter: Honour the short options documentation

Message ID GV1P250MB07370FF11238735826C9580A8F382@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 0c800c0b48f94edfa82e4bd4579ef3f27fdc49c2
Headers show
Series [FFmpeg-devel,01/10] avcodec/libvpxenc: Avoid unused-variable warning if VP9 enc is disabled | expand


Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt March 31, 2024, 5:31 a.m. UTC
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 | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
diff mbox series


diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 508fe1b26b..21d6832deb 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -846,9 +846,7 @@  int ff_filter_opt_parse(void *logctx, const AVClass *priv_class,
         const char *shorthand = NULL;
         int additional_flags  = 0;
-        if (priv_class)
-            o = av_opt_next(&priv_class, o);
-        if (o) {
+        if (priv_class && (o = av_opt_next(&priv_class, o))) {
             if (o->type == AV_OPT_TYPE_CONST || o->offset == offset)
             offset = o->offset;
@@ -871,9 +869,7 @@  int ff_filter_opt_parse(void *logctx, const AVClass *priv_class,
         if (parsed_key) {
             key = parsed_key;
             additional_flags = AV_DICT_DONT_STRDUP_KEY;
-            /* discard all remaining shorthand */
-            if (priv_class)
-                while ((o = av_opt_next(&priv_class, o)));
+            priv_class = NULL; /* reject all remaining shorthand */
         } else {
             key = shorthand;