diff mbox series

[FFmpeg-devel,03/10] avfilter/avfilter: Use AV_DICT_DONT_STRDUP_(KEY|VAL) when possible

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

Checks

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
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavfilter/avfilter.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c
index 856862a393..508fe1b26b 100644
--- a/libavfilter/avfilter.c
+++ b/libavfilter/avfilter.c
@@ -844,6 +844,7 @@  int ff_filter_opt_parse(void *logctx, const AVClass *priv_class,
 
     while (*args) {
         const char *shorthand = NULL;
+        int additional_flags  = 0;
 
         if (priv_class)
             o = av_opt_next(&priv_class, o);
@@ -869,7 +870,7 @@  int ff_filter_opt_parse(void *logctx, const AVClass *priv_class,
             args++;
         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)));
@@ -879,10 +880,8 @@  int ff_filter_opt_parse(void *logctx, const AVClass *priv_class,
 
         av_log(logctx, AV_LOG_DEBUG, "Setting '%s' to value '%s'\n", key, value);
 
-        av_dict_set(options, key, value, AV_DICT_MULTIKEY);
-
-        av_free(value);
-        av_free(parsed_key);
+        av_dict_set(options, key, value,
+                    additional_flags | AV_DICT_DONT_STRDUP_VAL | AV_DICT_MULTIKEY);
     }
 
     return 0;