diff mbox series

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

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

Patch

diff --git a/libavformat/aadec.c b/libavformat/aadec.c
index 70df0439bd..247c498147 100644
--- a/libavformat/aadec.c
+++ b/libavformat/aadec.c
@@ -175,10 +175,8 @@  static int aa_read_header(AVFormatContext *s)
 
     /* decoder setup */
     st = avformat_new_stream(s, NULL);
-    if (!st) {
-        av_freep(&c->tea_ctx);
+    if (!st)
         return AVERROR(ENOMEM);
-    }
     st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
     if (!strcmp(codec_name, "mp332")) {
         st->codecpar->codec_id = AV_CODEC_ID_MP3;
@@ -230,10 +228,8 @@  static int aa_read_header(AVFormatContext *s)
         avio_skip(pb, 4 + chapter_size);
         if (!avpriv_new_chapter(s, chapter_idx, st->time_base,
                                 chapter_pos * TIMEPREC,
-                                (chapter_pos + chapter_size) * TIMEPREC, NULL)) {
-            av_freep(&c->tea_ctx);
+                                (chapter_pos + chapter_size) * TIMEPREC, NULL))
             return AVERROR(ENOMEM);
-        }
     }
 
     st->duration = (largest_size - CHAPTER_HEADER_SIZE * s->nb_chapters) * TIMEPREC;
@@ -418,4 +414,5 @@  const AVInputFormat ff_aa_demuxer = {
     .read_seek      = aa_read_seek,
     .read_close     = aa_read_close,
     .flags          = AVFMT_NO_BYTE_SEEK | AVFMT_NOGENSEARCH,
+    .flags_internal = FF_FMT_INIT_CLEANUP,
 };