diff mbox series

[FFmpeg-devel,08/54] avformat/aqtitledec: Simplify cleanup after read_header failure

Message ID HE1PR0301MB2154B8CB79FBAAA00BFDD2518F309@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit 0de329e8e892d300e0d16e54ee70269e3d335e56
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:31 p.m. UTC
by setting the FF_FMT_INIT_CLEANUP flag.

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

Patch

diff --git a/libavformat/aqtitledec.c b/libavformat/aqtitledec.c
index de28097f2f..a37c9bbeaf 100644
--- a/libavformat/aqtitledec.c
+++ b/libavformat/aqtitledec.c
@@ -81,11 +81,11 @@  static int aqt_read_header(AVFormatContext *s)
             if (!new_event) {
                 sub = ff_subtitles_queue_insert(&aqt->q, "\n", 1, 1);
                 if (!sub)
-                    goto fail;
+                    return AVERROR(ENOMEM);
             }
             sub = ff_subtitles_queue_insert(&aqt->q, line, strlen(line), !new_event);
             if (!sub)
-                goto fail;
+                return AVERROR(ENOMEM);
             if (new_event) {
                 sub->pts = frame;
                 sub->duration = -1;
@@ -97,9 +97,6 @@  static int aqt_read_header(AVFormatContext *s)
 
     ff_subtitles_queue_finalize(s, &aqt->q);
     return 0;
-fail:
-    ff_subtitles_queue_clean(&aqt->q);
-    return AVERROR(ENOMEM);
 }
 
 static int aqt_read_packet(AVFormatContext *s, AVPacket *pkt)
@@ -141,6 +138,7 @@  const AVInputFormat ff_aqtitle_demuxer = {
     .name           = "aqtitle",
     .long_name      = NULL_IF_CONFIG_SMALL("AQTitle subtitles"),
     .priv_data_size = sizeof(AQTitleContext),
+    .flags_internal = FF_FMT_INIT_CLEANUP,
     .read_probe     = aqt_probe,
     .read_header    = aqt_read_header,
     .read_packet    = aqt_read_packet,