diff mbox series

[FFmpeg-devel,8/9] avformat/paf: Simplify cleanup after read_header failure

Message ID 20200721021215.32647-6-andreas.rheinhardt@gmail.com
State Superseded
Headers show
Series [FFmpeg-devel,v2,1/2] avformat: Redo cleanup of demuxer upon read_header() failure | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt July 21, 2020, 2:12 a.m. UTC
by setting the AVFMT_HEADER_CLEANUP flag.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/paf.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/paf.c b/libavformat/paf.c
index a31d01502b..9072c79edd 100644
--- a/libavformat/paf.c
+++ b/libavformat/paf.c
@@ -90,7 +90,6 @@  static int read_header(AVFormatContext *s)
     PAFDemuxContext *p  = s->priv_data;
     AVIOContext     *pb = s->pb;
     AVStream        *ast, *vst;
-    int ret = 0;
 
     avio_skip(pb, 132);
 
@@ -165,8 +164,7 @@  static int read_header(AVFormatContext *s)
         !p->video_frame         ||
         !p->audio_frame         ||
         !p->temp_audio_frame) {
-        ret = AVERROR(ENOMEM);
-        goto fail;
+        return AVERROR(ENOMEM);
     }
 
     avio_seek(pb, p->buffer_size, SEEK_SET);
@@ -182,11 +180,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)
@@ -260,6 +253,7 @@  static int read_packet(AVFormatContext *s, AVPacket *pkt)
 AVInputFormat ff_paf_demuxer = {
     .name           = "paf",
     .long_name      = NULL_IF_CONFIG_SMALL("Amazing Studio Packed Animation File"),
+    .flags          = AVFMT_HEADER_CLEANUP,
     .priv_data_size = sizeof(PAFDemuxContext),
     .read_probe     = read_probe,
     .read_header    = read_header,