diff mbox series

[FFmpeg-devel,7/7] avformat/segafilmenc: Add deinit function

Message ID 20200114031336.24096-7-andreas.rheinhardt@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/7] avformat/segafilmenc: Fix undefined left shift of 1 by 31 places
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Andreas Rheinhardt Jan. 14, 2020, 3:13 a.m. UTC
Prevents memleaks when the trailer is never written or when shifting the
data fails when writing the trailer.

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

Comments

Michael Niedermayer Feb. 25, 2020, 4:53 p.m. UTC | #1
On Tue, Jan 14, 2020 at 04:13:36AM +0100, Andreas Rheinhardt wrote:
> Prevents memleaks when the trailer is never written or when shifting the
> data fails when writing the trailer.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/segafilmenc.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)

will apply

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/segafilmenc.c b/libavformat/segafilmenc.c
index 137f153331..6b66c68328 100644
--- a/libavformat/segafilmenc.c
+++ b/libavformat/segafilmenc.c
@@ -360,10 +360,23 @@  static int film_write_header(AVFormatContext *format_context)
         packet = packet->next;
         av_freep(&prev);
     }
+    film->start = film->last = NULL;
 
     return 0;
 }
 
+static void film_deinit(AVFormatContext *format_context)
+{
+    FILMOutputContext *film = format_context->priv_data;
+    FILMPacket *packet = film->start;
+    while (packet != NULL) {
+        FILMPacket *next = packet->next;
+        av_free(packet);
+        packet = next;
+    }
+    film->start = film->last = NULL;
+}
+
 AVOutputFormat ff_segafilm_muxer = {
     .name           = "film_cpk",
     .long_name      = NULL_IF_CONFIG_SMALL("Sega FILM / CPK"),
@@ -374,4 +387,5 @@  AVOutputFormat ff_segafilm_muxer = {
     .init           = film_init,
     .write_trailer  = film_write_header,
     .write_packet   = film_write_packet,
+    .deinit         = film_deinit,
 };