[vlc-devel] commit: Cleaning (don't a message when the system runs out of memory) and fix a potential segfault. ( Rémi Duraffort )

git version control git at videolan.org
Tue Oct 14 23:18:09 CEST 2008


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Tue Oct 14 21:16:59 2008 +0200| [bfbd38a608a4df61c06c21eee6325e13ff7fedd3] | committer: Rémi Duraffort 

Cleaning (don't a message when the system runs out of memory) and fix a potential segfault.

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

 modules/access/screen/screen.c  |    4 +---
 modules/access/v4l2/v4l2.c      |    3 ---
 modules/access_output/rtmp.c    |    3 ---
 modules/control/http/http.c     |    3 ---
 modules/demux/mp4/libmp4.c      |    7 -------
 modules/demux/real.c            |    3 ---
 modules/gui/pda/pda_callbacks.c |    8 --------
 modules/misc/notify/notify.c    |    3 ---
 modules/misc/osd/osd_menu.c     |    3 ---
 src/input/stream.c              |   14 +++-----------
 10 files changed, 4 insertions(+), 47 deletions(-)

diff --git a/modules/access/screen/screen.c b/modules/access/screen/screen.c
index aff35f8..8287967 100644
--- a/modules/access/screen/screen.c
+++ b/modules/access/screen/screen.c
@@ -341,9 +341,7 @@ void RenderCursor( demux_t *p_demux, int i_x, int i_y,
     if( !p_sys->p_blend )
     {
         p_sys->p_blend = vlc_object_create( p_demux, sizeof(filter_t) );
-        if( !p_sys->p_blend )
-            msg_Err( p_demux, "Could not allocate memory for blending module" );
-        else
+        if( p_sys->p_blend )
         {
             es_format_Init( &p_sys->p_blend->fmt_in, VIDEO_ES,
                             VLC_FOURCC('R','G','B','A') );
diff --git a/modules/access/v4l2/v4l2.c b/modules/access/v4l2/v4l2.c
index f985e50..ebfe3e2 100644
--- a/modules/access/v4l2/v4l2.c
+++ b/modules/access/v4l2/v4l2.c
@@ -1717,10 +1717,7 @@ static int InitMmap( demux_t *p_demux, int i_fd )
 
     p_sys->p_buffers = calloc( req.count, sizeof( *p_sys->p_buffers ) );
     if( !p_sys->p_buffers )
-    {
-        msg_Err( p_demux, "Out of memory" );
         goto open_failed;
-    }
 
     for( p_sys->i_nbuffers = 0; p_sys->i_nbuffers < req.count; ++p_sys->i_nbuffers )
     {
diff --git a/modules/access_output/rtmp.c b/modules/access_output/rtmp.c
index 8afbf95..bc7caa3 100644
--- a/modules/access_output/rtmp.c
+++ b/modules/access_output/rtmp.c
@@ -90,10 +90,7 @@ static int Open( vlc_object_t *p_this )
     int i;
 
     if( !( p_sys = calloc ( 1, sizeof( sout_access_out_sys_t ) ) ) )
-    {
-        msg_Err( p_access, "not enough memory" );
         return VLC_ENOMEM;
-    }
     p_access->p_sys = p_sys;
 
     p_sys->p_thread =
diff --git a/modules/control/http/http.c b/modules/control/http/http.c
index bf706fe..08becdf 100644
--- a/modules/control/http/http.c
+++ b/modules/control/http/http.c
@@ -263,10 +263,7 @@ static int Open( vlc_object_t *p_this )
         /* FIXME: we're leaking h */
         httpd_handler_sys_t *h = malloc( sizeof( httpd_handler_sys_t ) );
         if( !h )
-        {
-            msg_Err( p_intf, "not enough memory to allocate album art handler" );
             goto failed;
-        }
         h->file.p_intf = p_intf;
         h->file.file = NULL;
         h->file.name = NULL;
diff --git a/modules/demux/mp4/libmp4.c b/modules/demux/mp4/libmp4.c
index cebdd94..71a9837 100644
--- a/modules/demux/mp4/libmp4.c
+++ b/modules/demux/mp4/libmp4.c
@@ -1872,10 +1872,7 @@ static int MP4_ReadBox_cmvd( stream_t *p_stream, MP4_Box_t *p_box )
     p_box->data.p_cmvd->i_compressed_size = i_read;
 
     if( !( p_box->data.p_cmvd->p_data = malloc( i_read ) ) )
-    {
-        msg_Dbg( p_stream, "read box: \"cmvd\" not enough memory to load data" );
         return( 1 );
-    }
 
     /* now copy compressed data */
     memcpy( p_box->data.p_cmvd->p_data,
@@ -1949,11 +1946,7 @@ static int MP4_ReadBox_cmov( stream_t *p_stream, MP4_Box_t *p_box )
     /* decompress data */
     /* allocate a new buffer */
     if( !( p_data = malloc( p_cmvd->data.p_cmvd->i_uncompressed_size ) ) )
-    {
-        msg_Err( p_stream, "read box: \"cmov\" not enough memory to "
-                 "uncompress data" );
         return 1;
-    }
     /* init default structures */
     z_data.next_in   = p_cmvd->data.p_cmvd->p_data;
     z_data.avail_in  = p_cmvd->data.p_cmvd->i_compressed_size;
diff --git a/modules/demux/real.c b/modules/demux/real.c
index 8d6fa6c..571b6f8 100644
--- a/modules/demux/real.c
+++ b/modules/demux/real.c
@@ -931,10 +931,7 @@ static void ReadRealIndex( demux_t *p_demux )
     p_sys->p_index = 
             (rm_index_t *)malloc( sizeof( rm_index_t ) * (i_index_count+1) );
     if( p_sys->p_index == NULL )
-    {
-        msg_Err( p_demux, "Memory allocation error" ); 
         return;
-    }
 
     memset( p_sys->p_index, 0, sizeof(rm_index_t) * (i_index_count+1) );
 
diff --git a/modules/gui/pda/pda_callbacks.c b/modules/gui/pda/pda_callbacks.c
index 2f8ffd1..9165fcd 100644
--- a/modules/gui/pda/pda_callbacks.c
+++ b/modules/gui/pda/pda_callbacks.c
@@ -655,16 +655,12 @@ void onAddCameraToPlaylist(GtkButton *button, gpointer user_data)
 
     ppsz_options = (char **) malloc(11 *sizeof(char*));
     if (ppsz_options == NULL)
-    {
-        msg_Err(p_intf, "No memory to allocate for v4l options.");
         return;
-    }
     for (i=0; i<11; i++)
     {
         ppsz_options[i] = (char *) malloc(VLC_MAX_MRL * sizeof(char));
         if (ppsz_options[i] == NULL)
         {
-            msg_Err(p_intf, "No memory to allocate for v4l options string %i.", i);
             for (i-=1; i>=0; i--)
                 free(ppsz_options[i]);
             free(ppsz_options);
@@ -1021,16 +1017,12 @@ void onAddTranscodeToPlaylist(GtkButton *button, gpointer user_data)
 
     ppsz_options = (char **) malloc(3 *sizeof(char*));
     if (ppsz_options == NULL)
-    {
-        msg_Err(p_intf, "No memory to allocate for v4l options.");
         return;
-    }
     for (i=0; i<3; i++)
     {
         ppsz_options[i] = (char *) malloc(VLC_MAX_MRL * sizeof(char));
         if (ppsz_options[i] == NULL)
         {
-            msg_Err(p_intf, "No memory to allocate for v4l options string %i.", i);
             for (i-=1; i>=0; i--)
                 free(ppsz_options[i]);
             free(ppsz_options);
diff --git a/modules/misc/notify/notify.c b/modules/misc/notify/notify.c
index e76903a..f1bcf9a 100644
--- a/modules/misc/notify/notify.c
+++ b/modules/misc/notify/notify.c
@@ -87,10 +87,7 @@ static int Open( vlc_object_t *p_this )
     intf_sys_t      *p_sys  = malloc( sizeof( intf_sys_t ) );
 
     if( !p_sys )
-    {
-        msg_Err( p_intf, "Out of memory" );
         return VLC_ENOMEM;
-    }
 
     if( !notify_init( APPLICATION_NAME ) )
     {
diff --git a/modules/misc/osd/osd_menu.c b/modules/misc/osd/osd_menu.c
index 2be6c92..f85cfc0 100644
--- a/modules/misc/osd/osd_menu.c
+++ b/modules/misc/osd/osd_menu.c
@@ -56,10 +56,7 @@ osd_menu_t *osd_MenuNew( osd_menu_t *p_menu, const char *psz_path,
 
     p_menu->p_state = (osd_menu_state_t *) malloc( sizeof( osd_menu_state_t ) );
     if( !p_menu->p_state )
-    {
-        msg_Err( p_menu, "Memory allocation for OSD Menu state failed" );
         return NULL;
-    }
 
     memset(p_menu->p_state, 0, sizeof(osd_menu_state_t));
     if( psz_path != NULL )
diff --git a/src/input/stream.c b/src/input/stream.c
index 4688cea..a6f16b0 100644
--- a/src/input/stream.c
+++ b/src/input/stream.c
@@ -460,16 +460,12 @@ stream_t *stream_AccessNew( access_t *p_access, bool b_quick )
         p_sys->immediate.i_end = 0;
         p_sys->immediate.p_buffer = malloc( STREAM_CACHE_SIZE );
 
+        if( p_sys->immediate.p_buffer == NULL )
+            goto error;
+
         msg_Dbg( s, "p_buffer %p-%p",
                  p_sys->immediate.p_buffer,
                  &p_sys->immediate.p_buffer[STREAM_CACHE_SIZE] );
-
-        if( p_sys->immediate.p_buffer == NULL )
-        {
-            msg_Err( s, "Out of memory when allocating stream cache (%d bytes)",
-                        STREAM_CACHE_SIZE );
-            goto error;
-        }
     }
     else
     {
@@ -487,11 +483,7 @@ stream_t *stream_AccessNew( access_t *p_access, bool b_quick )
         p_sys->stream.i_tk     = 0;
         p_sys->stream.p_buffer = malloc( STREAM_CACHE_SIZE );
         if( p_sys->stream.p_buffer == NULL )
-        {
-            msg_Err( s, "Out of memory when allocating stream cache (%d bytes)",
-                        STREAM_CACHE_SIZE );
             goto error;
-        }
         p_sys->stream.i_used   = 0;
         access_Control( p_access, ACCESS_GET_MTU,
                          &p_sys->stream.i_read_size );




More information about the vlc-devel mailing list