[vlc-devel] commit: Fix CID 103: resource leak in EsOutAdd and check malloc return values. ( Jean-Paul Saman )

git version control git at videolan.org
Sat May 31 17:12:52 CEST 2008


vlc | branch: master | Jean-Paul Saman <jpsaman at videolan.org> | Sat May 31 17:13:43 2008 +0200| [81c68015ca4dd00cb35d1784040a48e5915c7989]

Fix CID 103: resource leak in EsOutAdd and check malloc return values.

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

 src/input/es_out.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/src/input/es_out.c b/src/input/es_out.c
index 42c12eb..b5ac3dc 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -183,6 +183,13 @@ es_out_t *input_EsOutNew( input_thread_t *p_input, int i_rate )
     vlc_value_t  val;
     int i;
 
+    if( !out ) return NULL;
+    if( !p_sys )
+    {
+        free( out );
+        return NULL;
+    }
+
     out->pf_add     = EsOutAdd;
     out->pf_send    = EsOutSend;
     out->pf_del     = EsOutDel;
@@ -570,6 +577,7 @@ static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, int i_group )
     vlc_value_t       val;
 
     es_out_pgrm_t *p_pgrm = malloc( sizeof( es_out_pgrm_t ) );
+    if( !p_pgrm ) return NULL;
 
     /* Init */
     p_pgrm->i_id = i_group;
@@ -889,9 +897,12 @@ static es_out_id_t *EsOutAdd( es_out_t *out, es_format_t *fmt )
     es_out_pgrm_t     *p_pgrm = NULL;
     int i;
 
+    if( !es ) return NULL;
+
     if( fmt->i_group < 0 )
     {
         msg_Err( p_input, "invalid group number" );
+        free( es );
         return NULL;
     }
 




More information about the vlc-devel mailing list