Fixes: CID1539099 Resource leak

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc>
---
 fftools/ffmpeg.h          | 9 +++++++--
 fftools/ffmpeg_mux_init.c | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 885a7c0c102..7fd6c57d50f 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -868,7 +868,7 @@ void update_benchmark(const char *fmt, ...);
            namestr, st->index, o->optname.opt_canon->name, spec[0] ? ":" : "", 
spec, so->u.type);\
 }
 
-#define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
+#define MATCH_PER_STREAM_OPT_CLEAN(name, type, outvar, fmtctx, st, clean)\
 {\
     int _ret, _matches = 0, _match_idx;\
     for (int _i = 0; _i < o->name.nb_opt; _i++) {\
@@ -878,12 +878,17 @@ void update_benchmark(const char *fmt, ...);
             _match_idx = _i;\
             _matches++;\
         } else if (_ret < 0)\
-            return _ret;\
+            clean;\
     }\
     if (_matches > 1 && o->name.opt_canon)\
        WARN_MULTIPLE_OPT_USAGE(name, type, _match_idx, st);\
 }
 
+#define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
+{\
+    MATCH_PER_STREAM_OPT_CLEAN(name, type, outvar, fmtctx, st, return _ret)\
+}
+
 const char *opt_match_per_type_str(const SpecifierOptList *sol,
                                    char mediatype);
 
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index b1cb6cf7bd7..1262630b24e 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -2933,7 +2933,7 @@ static int set_dispositions(Muxer *mux, const 
OptionsContext *o)
 
         nb_streams[ost->type + 1]++;
 
-        MATCH_PER_STREAM_OPT(disposition, str, dispositions[i], ctx, ost->st);
+        MATCH_PER_STREAM_OPT_CLEAN(disposition, str, dispositions[i], ctx, 
ost->st, goto finish);
 
         have_manual |= !!dispositions[i];
 
-- 
2.43.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to