diff mbox

[FFmpeg-devel,1/6] avformat/aiffenc: Add deinit function

Message ID 20191023125944.10292-1-andreas.rheinhardt@gmail.com
State Superseded
Headers show

Commit Message

Andreas Rheinhardt Oct. 23, 2019, 12:59 p.m. UTC
Prevents memleaks if the trailer is never written.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/aiffenc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Comments

Michael Niedermayer Oct. 24, 2019, 5:38 p.m. UTC | #1
On Wed, Oct 23, 2019 at 02:59:39PM +0200, Andreas Rheinhardt wrote:
> Prevents memleaks if the trailer is never written.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/aiffenc.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
> index d09c9afb95..4f24c2a28c 100644
> --- a/libavformat/aiffenc.c
> +++ b/libavformat/aiffenc.c
> @@ -1,3 +1,4 @@
> +
>  /*
>   * AIFF/AIFF-C muxer
>   * Copyright (c) 2006  Patrick Guimond

stray change

[...]
diff mbox

Patch

diff --git a/libavformat/aiffenc.c b/libavformat/aiffenc.c
index d09c9afb95..4f24c2a28c 100644
--- a/libavformat/aiffenc.c
+++ b/libavformat/aiffenc.c
@@ -1,3 +1,4 @@ 
+
 /*
  * AIFF/AIFF-C muxer
  * Copyright (c) 2006  Patrick Guimond
@@ -260,7 +261,7 @@  static int aiff_write_trailer(AVFormatContext *s)
         /* Write ID3 tags */
         if (aiff->write_id3v2)
             if ((ret = put_id3v2_tags(s, aiff)) < 0)
-                goto free;
+                return ret;
 
         /* File length */
         file_size = avio_tell(pb);
@@ -270,12 +271,16 @@  static int aiff_write_trailer(AVFormatContext *s)
         avio_flush(pb);
     }
 
-free:
-    ff_packet_list_free(&aiff->pict_list, &aiff->pict_list_end);
-
     return ret;
 }
 
+static void aiff_deinit(AVFormatContext *s)
+{
+    AIFFOutputContext *aiff = s->priv_data;
+
+    ff_packet_list_free(&aiff->pict_list, &aiff->pict_list_end);
+}
+
 #define OFFSET(x) offsetof(AIFFOutputContext, x)
 #define ENC AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
@@ -304,6 +309,7 @@  AVOutputFormat ff_aiff_muxer = {
     .write_header      = aiff_write_header,
     .write_packet      = aiff_write_packet,
     .write_trailer     = aiff_write_trailer,
+    .deinit            = aiff_deinit,
     .codec_tag         = (const AVCodecTag* const []){ ff_codec_aiff_tags, 0 },
     .priv_class        = &aiff_muxer_class,
 };