diff mbox series

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

Message ID HE1PR0301MB2154B155EAE57E1AE48DCF4F8F309@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Commit 3da2f4502ae679370cec535990e41a0d2ea9ea90
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/xmv.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/xmv.c b/libavformat/xmv.c
index 36816ec005..fbe0f484e2 100644
--- a/libavformat/xmv.c
+++ b/libavformat/xmv.c
@@ -149,7 +149,6 @@  static int xmv_read_header(AVFormatContext *s)
     uint32_t file_version;
     uint32_t this_packet_size;
     uint16_t audio_track;
-    int ret;
 
     s->ctx_flags |= AVFMTCTX_NOHEADER;
 
@@ -177,10 +176,8 @@  static int xmv_read_header(AVFormatContext *s)
     avio_skip(pb, 2); /* Unknown (padding?) */
 
     xmv->audio = av_mallocz_array(xmv->audio_track_count, sizeof(XMVAudioPacket));
-    if (!xmv->audio) {
-        ret = AVERROR(ENOMEM);
-        goto fail;
-    }
+    if (!xmv->audio)
+        return AVERROR(ENOMEM);
 
     for (audio_track = 0; audio_track < xmv->audio_track_count; audio_track++) {
         XMVAudioPacket *packet = &xmv->audio[audio_track];
@@ -214,8 +211,7 @@  static int xmv_read_header(AVFormatContext *s)
              packet->channels >= UINT16_MAX / XMV_BLOCK_ALIGN_SIZE) {
             av_log(s, AV_LOG_ERROR, "Invalid parameters for audio track %"PRIu16".\n",
                    audio_track);
-            ret = AVERROR_INVALIDDATA;
-            goto fail;
+            return AVERROR_INVALIDDATA;
         }
     }
 
@@ -227,10 +223,6 @@  static int xmv_read_header(AVFormatContext *s)
     xmv->stream_count       = xmv->audio_track_count + 1;
 
     return 0;
-
-fail:
-    xmv_read_close(s);
-    return ret;
 }
 
 static void xmv_read_extradata(uint8_t *extradata, AVIOContext *pb)
@@ -588,6 +580,7 @@  const AVInputFormat ff_xmv_demuxer = {
     .long_name      = NULL_IF_CONFIG_SMALL("Microsoft XMV"),
     .extensions     = "xmv",
     .priv_data_size = sizeof(XMVDemuxContext),
+    .flags_internal = FF_FMT_INIT_CLEANUP,
     .read_probe     = xmv_probe,
     .read_header    = xmv_read_header,
     .read_packet    = xmv_read_packet,