[vlc-devel] commit: Check malloc return value and fix warnings. ( Rémi Duraffort )

git version control git at videolan.org
Wed Aug 20 23:19:35 CEST 2008


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Wed Aug 20 23:03:42 2008 +0200| [9e1c977b70efe72d8dc5fc580b65c4ff8f32fa3d] | committer: Rémi Duraffort 

Check malloc return value and fix warnings.

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

 modules/mux/ogg.c |   21 +++++++++++++++++++++
 modules/mux/wav.c |    2 ++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/modules/mux/ogg.c b/modules/mux/ogg.c
index 95bda99..ed60f58 100644
--- a/modules/mux/ogg.c
+++ b/modules/mux/ogg.c
@@ -218,6 +218,8 @@ static int Open( vlc_object_t *p_this )
     msg_Info( p_mux, "Open" );
 
     p_sys                 = malloc( sizeof( sout_mux_sys_t ) );
+    if( !p_sys )
+        return VLC_ENOMEM;
     p_sys->i_streams      = 0;
     p_sys->i_add_streams  = 0;
     p_sys->i_del_streams  = 0;
@@ -319,6 +321,8 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
     msg_Dbg( p_mux, "adding input" );
 
     p_input->p_sys = p_stream = malloc( sizeof( ogg_stream_t ) );
+    if( !p_stream )
+        return VLC_ENOMEM;
 
     p_stream->i_cat       = p_input->p_fmt->i_cat;
     p_stream->i_fourcc    = p_input->p_fmt->i_codec;
@@ -350,6 +354,11 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
         case VLC_FOURCC( 'S', 'N', 'O', 'W' ):
         case VLC_FOURCC( 'd', 'r', 'a', 'c' ):
             p_stream->p_oggds_header = malloc( sizeof(oggds_header_t) );
+            if( !p_stream->p_oggds_header )
+            {
+                free( p_stream );
+                return VLC_ENOMEM;
+            }
             memset( p_stream->p_oggds_header, 0, sizeof(oggds_header_t) );
             p_stream->p_oggds_header->i_packet_type = PACKET_TYPE_HEADER;
 
@@ -418,6 +427,11 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
 
             p_stream->p_oggds_header =
                 malloc( sizeof(oggds_header_t) + p_input->p_fmt->i_extra );
+            if( !p_stream->p_oggds_header )
+            {
+                free( p_stream );
+                return VLC_ENOMEM;
+            }
             memset( p_stream->p_oggds_header, 0, sizeof(oggds_header_t) );
             p_stream->p_oggds_header->i_packet_type = PACKET_TYPE_HEADER;
 
@@ -458,6 +472,11 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
         {
         case VLC_FOURCC( 's', 'u','b', 't' ):
             p_stream->p_oggds_header = malloc( sizeof(oggds_header_t) );
+            if( !p_stream->p_oggds_header )
+            {
+                free( p_stream );
+                return VLC_ENOMEM;
+            }
             memset( p_stream->p_oggds_header, 0, sizeof(oggds_header_t) );
             p_stream->p_oggds_header->i_packet_type = PACKET_TYPE_HEADER;
 
@@ -537,6 +556,7 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
 static block_t *OggStreamFlush( sout_mux_t *p_mux,
                                 ogg_stream_state *p_os, mtime_t i_pts )
 {
+    (void)p_mux;
     block_t *p_og, *p_og_first = NULL;
     ogg_page og;
 
@@ -562,6 +582,7 @@ static block_t *OggStreamFlush( sout_mux_t *p_mux,
 static block_t *OggStreamPageOut( sout_mux_t *p_mux,
                                   ogg_stream_state *p_os, mtime_t i_pts )
 {
+    (void)p_mux;
     block_t *p_og, *p_og_first = NULL;
     ogg_page og;
 
diff --git a/modules/mux/wav.c b/modules/mux/wav.c
index ed522b6..2642131 100644
--- a/modules/mux/wav.c
+++ b/modules/mux/wav.c
@@ -110,6 +110,8 @@ static int Open( vlc_object_t *p_this )
     p_mux->pf_mux       = Mux;
 
     p_mux->p_sys = p_sys = malloc( sizeof( sout_mux_sys_t ) );
+    if( !p_sys )
+        return VLC_ENOMEM;
     p_sys->b_used   = false;
     p_sys->b_header = true;
     p_sys->i_data   = 0;




More information about the vlc-devel mailing list