diff mbox series

[FFmpeg-devel,40/54] avformat/sccdec: Simplify cleanup after read_header failure

Message ID HE1PR0301MB2154390D98BAA8D633084EB28F309@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit 9ef7582446bf792e11ff55cc5f7dbaf7a1d0d89c
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/sccdec.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/sccdec.c b/libavformat/sccdec.c
index 5ad21a1f8b..e59e015bbc 100644
--- a/libavformat/sccdec.c
+++ b/libavformat/sccdec.c
@@ -145,7 +145,7 @@  static int scc_read_header(AVFormatContext *s)
 
                 sub = ff_subtitles_queue_insert(&scc->q, out, i, 0);
                 if (!sub)
-                    goto fail;
+                    return AVERROR(ENOMEM);
 
                 sub->pos = pos;
                 pos += i;
@@ -164,7 +164,7 @@  static int scc_read_header(AVFormatContext *s)
 
         sub = ff_subtitles_queue_insert(&scc->q, out, i, 0);
         if (!sub)
-            goto fail;
+            return AVERROR(ENOMEM);
 
         sub->pos = pos;
         sub->pts = ts;
@@ -175,9 +175,6 @@  static int scc_read_header(AVFormatContext *s)
     ff_subtitles_queue_finalize(s, &scc->q);
 
     return 0;
-fail:
-    ff_subtitles_queue_clean(&scc->q);
-    return AVERROR(ENOMEM);
 }
 
 static int scc_read_packet(AVFormatContext *s, AVPacket *pkt)
@@ -205,6 +202,7 @@  const AVInputFormat ff_scc_demuxer = {
     .name           = "scc",
     .long_name      = NULL_IF_CONFIG_SMALL("Scenarist Closed Captions"),
     .priv_data_size = sizeof(SCCContext),
+    .flags_internal = FF_FMT_INIT_CLEANUP,
     .read_probe     = scc_probe,
     .read_header    = scc_read_header,
     .read_packet    = scc_read_packet,