Commit bfbd38a6 authored by Rémi Duraffort's avatar Rémi Duraffort

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

parent 825bf79e
......@@ -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') );
......
......@@ -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 )
{
......
......@@ -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 =
......
......@@ -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;
......
......@@ -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;
......
......@@ -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) );
......
......@@ -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);
......
......@@ -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 ) )
{
......
......@@ -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 )
......
......@@ -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 );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment