[FFmpeg-cvslog] avformat/gxfenc: Add deinit function

Andreas Rheinhardt git at videolan.org
Sun Jan 26 19:43:34 EET 2020


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Sun Jan 26 11:27:39 2020 +0100| [262b554358120a945c32045691a02ee1abea7841] | committer: Michael Niedermayer

avformat/gxfenc: Add deinit function

Fixes memleaks when the trailer is never written (e.g. if the call to
gxf_write_map_packet() at the end of gxf_write_header() fails).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=262b554358120a945c32045691a02ee1abea7841
---

 libavformat/gxfenc.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c
index e09b8d7625..9eebefc683 100644
--- a/libavformat/gxfenc.c
+++ b/libavformat/gxfenc.c
@@ -853,8 +853,6 @@ static int gxf_write_trailer(AVFormatContext *s)
     int i;
     int ret;
 
-    ff_audio_interleave_close(s);
-
     gxf_write_eos_packet(pb);
     end = avio_tell(pb);
     avio_seek(pb, 0, SEEK_SET);
@@ -872,10 +870,17 @@ static int gxf_write_trailer(AVFormatContext *s)
 
     avio_seek(pb, end, SEEK_SET);
 
+    return 0;
+}
+
+static void gxf_deinit(AVFormatContext *s)
+{
+    GXFContext *gxf = s->priv_data;
+
+    ff_audio_interleave_close(s);
+
     av_freep(&gxf->flt_entries);
     av_freep(&gxf->map_offsets);
-
-    return 0;
 }
 
 static int gxf_parse_mpeg_frame(GXFStreamContext *sc, const uint8_t *buf, int size)
@@ -1025,5 +1030,6 @@ AVOutputFormat ff_gxf_muxer = {
     .write_header      = gxf_write_header,
     .write_packet      = gxf_write_packet,
     .write_trailer     = gxf_write_trailer,
+    .deinit            = gxf_deinit,
     .interleave_packet = gxf_interleave_packet,
 };



More information about the ffmpeg-cvslog mailing list