[dvblast-devel] demux: Prevent double free in demux_Close().

Georgi Chorbadzhiyski git at videolan.org
Fri Apr 6 01:39:55 CEST 2012


dvblast | branch: master | Georgi Chorbadzhiyski <gf at unixsol.org> | Fri Apr  6 02:36:51 2012 +0300| [c2560f8c7ea02d973976d04016ca22aabdaa1ccf] | committer: Georgi Chorbadzhiyski

demux: Prevent double free in demux_Close().

demux_Close() is called after outputs_Close() which frees all outputs.
Trying to free the outputs again in demux_Close() results in double free
and with recent glibc, a segfault. demux_Close() should free the
allocated outputs array not each entry.

> http://git.videolan.org/gitweb.cgi/dvblast.git/?a=commit;h=c2560f8c7ea02d973976d04016ca22aabdaa1ccf
---

 demux.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/demux.c b/demux.c
index b4dbaac..a4a2316 100644
--- a/demux.c
+++ b/demux.c
@@ -208,7 +208,7 @@ void demux_Open( void )
  *****************************************************************************/
 void demux_Close( void )
 {
-    int i, j;
+    int i;
 
     psi_table_free( pp_current_pat_sections );
     psi_table_free( pp_next_pat_sections );
@@ -222,10 +222,7 @@ void demux_Close( void )
     for ( i = 0; i < MAX_PIDS; i++ )
     {
         free( p_pids[i].p_psi_buffer );
-        for ( j = 0; j < p_pids[i].i_nb_outputs; j++ )
-        {
-            free( p_pids[i].pp_outputs );
-        }
+        free( p_pids[i].pp_outputs );
     }
 
     for ( i = 0; i < i_nb_sids; i++ )



More information about the dvblast-devel mailing list