diff mbox series

[FFmpeg-devel,34/54] avformat/paf: Simplify cleanup after read_header failure

Message ID HE1PR0301MB2154A739370A7429D48582CB8F309@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit d2574262a538748a24ca2debecec33d8fe31df60
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/paf.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/paf.c b/libavformat/paf.c
index f48b2e60cd..2d2d7f8dd8 100644
--- a/libavformat/paf.c
+++ b/libavformat/paf.c
@@ -172,22 +172,20 @@  static int read_header(AVFormatContext *s)
         !p->blocks_offset_table ||
         !p->video_frame         ||
         !p->audio_frame         ||
-        !p->temp_audio_frame) {
-        ret = AVERROR(ENOMEM);
-        goto fail;
-    }
+        !p->temp_audio_frame)
+        return AVERROR(ENOMEM);
 
     avio_seek(pb, p->buffer_size, SEEK_SET);
 
     ret = read_table(s, p->blocks_count_table,  p->nb_frames);
     if (ret < 0)
-        goto fail;
+        return ret;
     ret = read_table(s, p->frames_offset_table, p->nb_frames);
     if (ret < 0)
-        goto fail;
+        return ret;
     ret = read_table(s, p->blocks_offset_table, p->frame_blks);
     if (ret < 0)
-        goto fail;
+        return ret;
 
     p->got_audio = 0;
     p->current_frame = 0;
@@ -196,11 +194,6 @@  static int read_header(AVFormatContext *s)
     avio_seek(pb, p->start_offset, SEEK_SET);
 
     return 0;
-
-fail:
-    read_close(s);
-
-    return ret;
 }
 
 static int read_packet(AVFormatContext *s, AVPacket *pkt)
@@ -275,6 +268,7 @@  const AVInputFormat ff_paf_demuxer = {
     .name           = "paf",
     .long_name      = NULL_IF_CONFIG_SMALL("Amazing Studio Packed Animation File"),
     .priv_data_size = sizeof(PAFDemuxContext),
+    .flags_internal = FF_FMT_INIT_CLEANUP,
     .read_probe     = read_probe,
     .read_header    = read_header,
     .read_packet    = read_packet,