diff mbox series

[FFmpeg-devel,23/54] avformat/microdvddec: Simplify cleanup after read_header failure

Message ID HE1PR0301MB2154343AB9576969677C46798F309@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit da45c89fe1792a12a9b0c5183fe22cf0df92814b
Headers show
Series [FFmpeg-devel,01/54] avformat: Add internal flags for AV(In|Out)putFormat
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt June 15, 2021, 11:32 p.m. UTC
by setting the FF_FMT_INIT_CLEANUP flag.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavformat/microdvddec.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/microdvddec.c b/libavformat/microdvddec.c
index 3c45c72595..e536d12b85 100644
--- a/libavformat/microdvddec.c
+++ b/libavformat/microdvddec.c
@@ -121,7 +121,7 @@  static int microdvd_read_header(AVFormatContext *s)
                 int size = strlen(line + 11);
                 ret = ff_alloc_extradata(st->codecpar, size);
                 if (ret < 0)
-                    goto fail;
+                    return ret;
                 memcpy(st->codecpar->extradata, line + 11, size);
                 continue;
             }
@@ -142,10 +142,8 @@  static int microdvd_read_header(AVFormatContext *s)
         if (pts == AV_NOPTS_VALUE)
             continue;
         sub = ff_subtitles_queue_insert(&microdvd->q, p, strlen(p), 0);
-        if (!sub) {
-            ret = AVERROR(ENOMEM);
-            goto fail;
-        }
+        if (!sub)
+            return AVERROR(ENOMEM);
         sub->pos = pos;
         sub->pts = pts;
         sub->duration = get_duration(line);
@@ -162,9 +160,6 @@  static int microdvd_read_header(AVFormatContext *s)
     st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
     st->codecpar->codec_id   = AV_CODEC_ID_MICRODVD;
     return 0;
-fail:
-    ff_subtitles_queue_clean(&microdvd->q);
-    return ret;
 }
 
 static int microdvd_read_packet(AVFormatContext *s, AVPacket *pkt)
@@ -207,6 +202,7 @@  const AVInputFormat ff_microdvd_demuxer = {
     .name           = "microdvd",
     .long_name      = NULL_IF_CONFIG_SMALL("MicroDVD subtitle format"),
     .priv_data_size = sizeof(MicroDVDContext),
+    .flags_internal = FF_FMT_INIT_CLEANUP,
     .read_probe     = microdvd_probe,
     .read_header    = microdvd_read_header,
     .read_packet    = microdvd_read_packet,