[FFmpeg-devel] [PATCH 22/54] avformat/mccdec: Simplify cleanup after read_header failure

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Wed Jun 16 02:32:11 EEST 2021


by setting the FF_FMT_INIT_CLEANUP flag.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavformat/mccdec.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavformat/mccdec.c b/libavformat/mccdec.c
index a096ac6e93..d206fc2d62 100644
--- a/libavformat/mccdec.c
+++ b/libavformat/mccdec.c
@@ -189,7 +189,7 @@ static int mcc_read_header(AVFormatContext *s)
             continue;
         sub = ff_subtitles_queue_insert(&mcc->q, out + start, count, 0);
         if (!sub)
-            goto fail;
+            return AVERROR(ENOMEM);
 
         sub->pos = pos;
         sub->pts = ts;
@@ -199,9 +199,6 @@ static int mcc_read_header(AVFormatContext *s)
     ff_subtitles_queue_finalize(s, &mcc->q);
 
     return ret;
-fail:
-    ff_subtitles_queue_clean(&mcc->q);
-    return AVERROR(ENOMEM);
 }
 
 static int mcc_read_packet(AVFormatContext *s, AVPacket *pkt)
@@ -229,6 +226,7 @@ const AVInputFormat ff_mcc_demuxer = {
     .name           = "mcc",
     .long_name      = NULL_IF_CONFIG_SMALL("MacCaption"),
     .priv_data_size = sizeof(MCCContext),
+    .flags_internal = FF_FMT_INIT_CLEANUP,
     .read_probe     = mcc_probe,
     .read_header    = mcc_read_header,
     .read_packet    = mcc_read_packet,
-- 
2.27.0



More information about the ffmpeg-devel mailing list