[vlc-commits] mux_mp4: fix memory leak

Rémi Denis-Courmont git at videolan.org
Sat Aug 22 09:25:32 CEST 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Aug 22 10:25:21 2015 +0300| [753d2bfbfbe5efcb20f44913d3064d9e4791f1af] | committer: Rémi Denis-Courmont

mux_mp4: fix memory leak

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=753d2bfbfbe5efcb20f44913d3064d9e4791f1af
---

 modules/mux/mp4.c |   11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/modules/mux/mp4.c b/modules/mux/mp4.c
index 47b838e..417cc60 100644
--- a/modules/mux/mp4.c
+++ b/modules/mux/mp4.c
@@ -37,6 +37,7 @@
 
 #include <vlc_bits.h>
 
+#include <assert.h>
 #include <time.h>
 
 #include <vlc_iso_lang.h>
@@ -45,7 +46,6 @@
 #include "../demux/mpeg/mpeg_parser_helpers.h"
 #include "../demux/mp4/libmp4.h"
 
-#include "assert.h"
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -277,9 +277,8 @@ static int Open(vlc_object_t *p_this)
             box_fix(box, box->b->i_buffer);
             p_sys->i_pos += box->b->i_buffer;
             p_sys->i_mdat_pos = p_sys->i_pos;
-
-            box_send(p_mux, box);
         }
+        box_send(p_mux, box);
     }
 
     /* FIXME FIXME
@@ -394,7 +393,8 @@ static void Close(vlc_object_t *p_this)
 
     /* Write MOOV header */
     sout_AccessOutSeek(p_mux->p_access, i_moov_pos);
-    box_send(p_mux, moov);
+    if (moov != NULL)
+        box_send(p_mux, moov);
 
 cleanup:
     /* Clean-up */
@@ -2463,7 +2463,8 @@ static void box_gather (bo_t *box, bo_t *box2)
 
 static void box_send(sout_mux_t *p_mux,  bo_t *box)
 {
-    if(box && box->b)
+    assert(box != NULL);
+    if (box->b)
         sout_AccessOutWrite(p_mux->p_access, box->b);
     free(box);
 }



More information about the vlc-commits mailing list