changeset 5738:7152149eb03f libavformat

Plug memory leak in NUT muxer and demuxer
author vitor
date Wed, 03 Mar 2010 17:31:24 +0000
parents 192d6ebe32ff
children 84bfac703b3a
files nut.c nut.h nutdec.c nutenc.c
diffstat 4 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/nut.c	Wed Mar 03 17:26:00 2010 +0000
+++ b/nut.c	Wed Mar 03 17:31:24 2010 +0000
@@ -69,6 +69,17 @@
     }
 }
 
+static void enu_free(void *opaque, void *elem)
+{
+    av_free(elem);
+}
+
+void ff_nut_free_sp(NUTContext *nut)
+{
+    av_tree_enumerate(nut->syncpoints, NULL, NULL, enu_free);
+    av_tree_destroy(nut->syncpoints);
+}
+
 const Dispositions ff_nut_dispositions[] = {
     {"default"     , AV_DISPOSITION_DEFAULT},
     {"dub"         , AV_DISPOSITION_DUB},
--- a/nut.h	Wed Mar 03 17:26:00 2010 +0000
+++ b/nut.h	Wed Mar 03 17:31:24 2010 +0000
@@ -110,6 +110,7 @@
 int ff_nut_sp_pos_cmp(Syncpoint *a, Syncpoint *b);
 int ff_nut_sp_pts_cmp(Syncpoint *a, Syncpoint *b);
 void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts);
+void ff_nut_free_sp(NUTContext *nut);
 
 extern const Dispositions ff_nut_dispositions[];
 
--- a/nutdec.c	Wed Mar 03 17:26:00 2010 +0000
+++ b/nutdec.c	Wed Mar 03 17:31:24 2010 +0000
@@ -901,6 +901,7 @@
 
     av_freep(&nut->time_base);
     av_freep(&nut->stream);
+    ff_nut_free_sp(nut);
     for(i = 1; i < nut->header_count; i++)
         av_freep(&nut->header[i]);
 
--- a/nutenc.c	Wed Mar 03 17:26:00 2010 +0000
+++ b/nutenc.c	Wed Mar 03 17:31:24 2010 +0000
@@ -797,6 +797,7 @@
     while(nut->header_count<3)
         write_headers(nut, bc);
     put_flush_packet(bc);
+    ff_nut_free_sp(nut);
     av_freep(&nut->stream);
     av_freep(&nut->time_base);