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

Remove unneeded msg_Error about memory failure.

Fix a double malloc.
Fix potential segfault.
parent 7d1d56fe
......@@ -634,7 +634,6 @@ int CDDAOpen( vlc_object_t *p_this )
p_cdda = calloc( 1, sizeof(cdda_data_t) );
if( p_cdda == NULL )
{
msg_Err( p_access, "out of memory" );
free( psz_source );
return VLC_ENOMEM;
}
......
......@@ -227,10 +227,7 @@ static int Open( vlc_object_t *p_this )
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
if( !p_sys )
{
msg_Err( p_demux, "not enough memory available" );
return VLC_ENOMEM;
}
memset( p_sys, 0, sizeof( demux_sys_t ) );
memset( &fmt, 0, sizeof( es_format_t ) );
......
......@@ -339,7 +339,7 @@ static int OpenWithCookies( vlc_object_t *p_this, vlc_array_t *cookies )
if (proxies[0])
{
msg_Dbg(p_access, "libproxy suggest to use '%s'", proxies[0]);
if(strcmp(proxies[0],"direct://") != 0)
if(strcmp(proxies[0],"direct://") != 0)
{
p_sys->b_proxy = true;
vlc_UrlParse( &p_sys->proxy, proxies[0], 0);
......
......@@ -88,10 +88,7 @@ static int Open( vlc_object_t *p_this )
p_sys->p_thread =
vlc_object_create( p_access, sizeof( rtmp_control_thread_t ) );
if( !p_sys->p_thread )
{
msg_Err( p_access, "out of memory" );
return VLC_ENOMEM;
}
vlc_object_attach( p_sys->p_thread, p_access );
/* Parse URI - remove spaces */
......
......@@ -1662,18 +1662,12 @@ static int InitRead( demux_t *p_demux, int i_fd, unsigned int i_buffer_size )
p_sys->p_buffers = calloc( 1, sizeof( *p_sys->p_buffers ) );
if( !p_sys->p_buffers )
{
msg_Err( p_demux, "Out of memory" );
goto open_failed;
}
p_sys->p_buffers[0].length = i_buffer_size;
p_sys->p_buffers[0].start = malloc( i_buffer_size );
if( !p_sys->p_buffers[0].start )
{
msg_Err( p_demux, "Out of memory" );
goto open_failed;
}
return VLC_SUCCESS;
......
......@@ -96,10 +96,7 @@ vcddev_t *ioctl_Open( vlc_object_t *p_this, const char *psz_dev )
*/
p_vcddev = (vcddev_t *)malloc( sizeof(vcddev_t) );
if( p_vcddev == NULL )
{
msg_Err( p_this, "out of memory" );
return NULL;
}
p_vcddev->i_vcdimage_handle = -1;
p_vcddev->psz_dev = NULL;
b_is_file = 1;
......@@ -211,10 +208,7 @@ int ioctl_GetTracksMap( vlc_object_t *p_this, const vcddev_t *p_vcddev,
{
*pp_sectors = malloc( (i_tracks + 1) * sizeof(int) );
if( *pp_sectors == NULL )
{
msg_Err( p_this, "out of memory" );
return 0;
}
memcpy( *pp_sectors, p_vcddev->p_sectors,
(i_tracks + 1) * sizeof(int) );
}
......@@ -251,7 +245,6 @@ int ioctl_GetTracksMap( vlc_object_t *p_this, const vcddev_t *p_vcddev,
*pp_sectors = malloc( (i_tracks + 1) * sizeof(int) );
if( *pp_sectors == NULL )
{
msg_Err( p_this, "out of memory" );
darwin_freeTOC( pTOC );
return 0;
}
......@@ -360,7 +353,6 @@ int ioctl_GetTracksMap( vlc_object_t *p_this, const vcddev_t *p_vcddev,
{
free( *pp_sectors );
free( p_fulltoc );
msg_Err( p_this, "out of memory" );
CloseHandle( hEvent );
return 0;
}
......@@ -423,10 +415,7 @@ int ioctl_GetTracksMap( vlc_object_t *p_this, const vcddev_t *p_vcddev,
*pp_sectors = malloc( (i_tracks + 1) * sizeof(int) );
if( *pp_sectors == NULL )
{
msg_Err( p_this, "out of memory" );
return 0;
}
for( i = 0 ; i <= i_tracks ; i++ )
{
......@@ -459,10 +448,7 @@ int ioctl_GetTracksMap( vlc_object_t *p_this, const vcddev_t *p_vcddev,
*pp_sectors = malloc( (i_tracks + 1) * sizeof(int) );
if( *pp_sectors == NULL )
{
msg_Err( p_this, "out of memory" );
return 0;
}
toc_entries.address_format = CD_LBA_FORMAT;
toc_entries.starting_track = 0;
......@@ -472,7 +458,6 @@ int ioctl_GetTracksMap( vlc_object_t *p_this, const vcddev_t *p_vcddev,
malloc( toc_entries.data_len );
if( toc_entries.data == NULL )
{
msg_Err( p_this, "out of memory" );
free( *pp_sectors );
return 0;
}
......@@ -518,10 +503,7 @@ int ioctl_GetTracksMap( vlc_object_t *p_this, const vcddev_t *p_vcddev,
*pp_sectors = malloc( (i_tracks + 1) * sizeof(int) );
if( *pp_sectors == NULL )
{
msg_Err( p_this, "out of memory" );
return 0;
}
/* Fill the p_sectors structure with the track/sector matches */
for( i = 0 ; i <= i_tracks ; i++ )
......
......@@ -106,10 +106,7 @@ static int Create( vlc_object_t *p_this )
/* Allocate the memory needed to store the module's structure */
p_filter->p_sys = malloc( sizeof(struct aout_filter_sys_t) );
if ( p_filter->p_sys == NULL )
{
msg_Err( p_filter, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
p_filter->p_sys->i_left = -1;
p_filter->p_sys->i_center = -1;
p_filter->p_sys->i_right = -1;
......
......@@ -245,10 +245,7 @@ static int Init( vlc_object_t *p_this, struct aout_filter_sys_t * p_data
p_data->p_atomic_operations = malloc( sizeof(struct atomic_operation_t)
* p_data->i_nb_atomic_operations );
if( p_data->p_atomic_operations == NULL )
{
msg_Err( p_this, "out of memory" );
return -1;
}
/* For each virtual speaker, computes elementary wave propagation time
* to each ear */
......@@ -346,10 +343,7 @@ static int Init( vlc_object_t *p_this, struct aout_filter_sys_t * p_data
}
p_data->p_overflow_buffer = malloc( p_data->i_overflow_buffer_size );
if( p_data->p_atomic_operations == NULL )
{
msg_Err( p_this, "out of memory" );
return -1;
}
memset( p_data->p_overflow_buffer, 0 , p_data->i_overflow_buffer_size );
/* end */
......@@ -411,10 +405,7 @@ static int Create( vlc_object_t *p_this )
/* Allocate the memory needed to store the module's structure */
p_filter->p_sys = malloc( sizeof(struct aout_filter_sys_t) );
if( p_filter->p_sys == NULL )
{
msg_Err( p_filter, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
p_filter->p_sys->i_overflow_buffer_size = 0;
p_filter->p_sys->p_overflow_buffer = NULL;
p_filter->p_sys->i_nb_atomic_operations = 0;
......@@ -626,10 +617,7 @@ static int OpenFilter( vlc_object_t *p_this )
/* Allocate the memory needed to store the module's structure */
p_filter->p_sys = malloc( sizeof(struct filter_sys_t) );
if( p_filter->p_sys == NULL )
{
msg_Err( p_filter, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
p_filter->p_sys->i_overflow_buffer_size = 0;
p_filter->p_sys->p_overflow_buffer = NULL;
p_filter->p_sys->i_nb_atomic_operations = 0;
......
......@@ -247,10 +247,7 @@ static int Init( vlc_object_t *p_this, struct filter_sys_t * p_data,
p_data->p_atomic_operations = malloc( sizeof(struct atomic_operation_t)
* p_data->i_nb_atomic_operations );
if( p_data->p_atomic_operations == NULL )
{
msg_Err( p_this, "out of memory" );
return -1;
}
/* For each virtual speaker, computes elementary wave propagation time
* to each ear */
......@@ -348,10 +345,7 @@ static int Init( vlc_object_t *p_this, struct filter_sys_t * p_data,
}
p_data->p_overflow_buffer = malloc( p_data->i_overflow_buffer_size );
if( p_data->p_atomic_operations == NULL )
{
msg_Err( p_this, "out of memory" );
return -1;
}
memset( p_data->p_overflow_buffer, 0, p_data->i_overflow_buffer_size );
/* end */
......@@ -393,10 +387,7 @@ static int OpenFilter( vlc_object_t *p_this )
/* Allocate the memory needed to store the module's structure */
p_sys = p_filter->p_sys = malloc( sizeof(filter_sys_t) );
if( p_sys == NULL )
{
msg_Err( p_filter, "out of memory" );
return VLC_EGENERIC;
}
var_Create( p_this, MONO_CFG "downmix",
VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
......
......@@ -149,10 +149,7 @@ static int Create( vlc_object_t *p_this )
p_sys = malloc( sizeof(filter_sys_t) );
p_filter->p_sys = (struct aout_filter_sys_t *)p_sys;
if( p_sys == NULL )
{
msg_Err( p_filter, "out of memory" );
return -1;
}
i_ret = Open( VLC_OBJECT(p_filter), p_sys,
p_filter->input, p_filter->output );
......@@ -444,10 +441,7 @@ static int OpenFilter( vlc_object_t *p_this )
/* Allocate the memory needed to store the module's structure */
p_filter->p_sys = p_sys = malloc( sizeof(filter_sys_t) );
if( p_sys == NULL )
{
msg_Err( p_filter, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
i_ret = Open( VLC_OBJECT(p_filter), p_sys,
p_filter->fmt_in.audio, p_filter->fmt_out.audio );
......
......@@ -128,10 +128,7 @@ static int Create( vlc_object_t *p_this )
p_sys = malloc( sizeof(filter_sys_t) );
p_filter->p_sys = (struct aout_filter_sys_t *)p_sys;
if( p_sys == NULL )
{
msg_Err( p_filter, "out of memory" );
return -1;
}
i_ret = Open( VLC_OBJECT(p_filter), p_sys,
p_filter->input, p_filter->output );
......@@ -402,18 +399,7 @@ static int OpenFilter( vlc_object_t *p_this )
/* Allocate the memory needed to store the module's structure */
p_sys = p_filter->p_sys = malloc( sizeof(filter_sys_t) );
if( p_sys == NULL )
{
msg_Err( p_filter, "out of memory" );
return VLC_EGENERIC;
}
/* Allocate the memory needed to store the module's structure */
p_filter->p_sys = p_sys = malloc( sizeof(filter_sys_t) );
if( p_sys == NULL )
{
msg_Err( p_filter, "out of memory" );
return VLC_EGENERIC;
}
return VLC_ENOMEM;
i_ret = Open( VLC_OBJECT(p_filter), p_sys,
p_filter->fmt_in.audio, p_filter->fmt_out.audio );
......
......@@ -91,10 +91,7 @@ static int Create( vlc_object_t *p_this )
/* Allocate the memory needed to store the module's structure */
p_filter->p_sys = malloc( sizeof(struct aout_filter_sys_t) );
if( p_filter->p_sys == NULL )
{
msg_Err( p_filter, "out of memory" );
return VLC_ENOMEM;
}
memset( p_filter->p_sys, 0, sizeof(struct aout_filter_sys_t) );
p_filter->p_sys->p_buf = 0;
......
......@@ -104,10 +104,7 @@ static int Create( vlc_object_t *p_this )
p_sys = malloc( sizeof(filter_sys_t) );
p_filter->p_sys = (struct aout_filter_sys_t *)p_sys;
if( p_sys == NULL )
{
msg_Err( p_filter, "out of memory" );
return -1;
}
/* Initialize libmad */
mad_stream_init( &p_sys->mad_stream );
......@@ -316,10 +313,7 @@ static int OpenFilter( vlc_object_t *p_this )
/* Allocate the memory needed to store the module's structure */
p_sys = p_filter->p_sys = malloc( sizeof(filter_sys_t) );
if( p_sys == NULL )
{
msg_Err( p_filter, "out of memory" );
return -1;
}
p_sys->i_reject_count = 0;
p_filter->pf_audio_filter = Convert;
......
......@@ -119,10 +119,7 @@ static int Create( vlc_object_t *p_this )
/* Allocate the memory needed to store the module's structure */
p_filter->p_sys = malloc( sizeof(struct aout_filter_sys_t) );
if( p_filter->p_sys == NULL )
{
msg_Err( p_filter, "out of memory" );
return VLC_ENOMEM;
}
/* Calculate worst case for the length of the filter wing */
d_factor = (double)p_filter->output.i_rate
......@@ -135,10 +132,7 @@ static int Create( vlc_object_t *p_this )
/* Allocate enough memory to buffer previous samples */
p_filter->p_sys->p_buf = malloc( p_filter->p_sys->i_buf_size );
if( p_filter->p_sys->p_buf == NULL )
{
msg_Err( p_filter, "out of memory" );
return VLC_ENOMEM;
}
p_filter->p_sys->i_old_wing = 0;
p_filter->pf_do_work = DoWork;
......
......@@ -99,17 +99,11 @@ static int Create( vlc_object_t *p_this )
p_sys = malloc( sizeof(filter_sys_t) );
p_filter->p_sys = (struct aout_filter_sys_t *)p_sys;
if( p_sys == NULL )
{
msg_Err( p_filter, "out of memory" );
return VLC_ENOMEM;
}
p_sys->p_prev_sample = malloc(
p_filter->input.i_channels * sizeof(int32_t) );
if( p_sys->p_prev_sample == NULL )
{
msg_Err( p_filter, "out of memory" );
return VLC_ENOMEM;
}
aout_DateInit( &p_sys->end_date, p_filter->output.i_rate );
p_filter->pf_do_work = DoWork;
......@@ -275,16 +269,12 @@ static int OpenFilter( vlc_object_t *p_this )
/* Allocate the memory needed to store the module's structure */
p_filter->p_sys = p_sys = malloc( sizeof(struct filter_sys_t) );
if( p_sys == NULL )
{
msg_Err( p_filter, "out of memory" );
return VLC_ENOMEM;
}
p_sys->p_prev_sample = malloc(
p_filter->fmt_in.audio.i_channels * sizeof(int32_t) );
if( p_sys->p_prev_sample == NULL )
{
msg_Err( p_filter, "out of memory" );
free( p_sys );
return VLC_ENOMEM;
}
......
......@@ -289,10 +289,7 @@ static int Create( vlc_object_t *p_this )
/* Allocate structure */
p_filter->p_sys = p_sys = malloc( sizeof( filter_sys_t ) );
if( !p_sys )
{
msg_Err( p_filter, "out of memory" );
return VLC_ENOMEM;
}
p_sys->p_face = 0;
p_sys->p_library = 0;
p_sys->i_font_size = 0;
......@@ -324,10 +321,7 @@ static int Create( vlc_object_t *p_this )
free( psz_fontfile );
psz_fontfile = (char *)malloc( PATH_MAX + 1 );
if( !psz_fontfile )
{
msg_Err( p_filter, "out of memory" );
goto error;
}
#ifdef WIN32
GetWindowsDirectory( psz_fontfile, PATH_MAX + 1 );
strcat( psz_fontfile, "\\fonts\\arial.ttf" );
......@@ -1128,10 +1122,7 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out,
psz_unicode = psz_unicode_orig =
malloc( ( strlen(psz_string) + 1 ) * sizeof(uint32_t) );
if( psz_unicode == NULL )
{
msg_Err( p_filter, "out of memory" );
goto error;
}
#if defined(WORDS_BIGENDIAN)
iconv_handle = vlc_iconv_open( "UCS-4BE", "UTF-8" );
#else
......@@ -1174,10 +1165,7 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out,
p_fribidi_string = malloc( (i_string_length + 1) * sizeof(uint32_t) );
if( !p_fribidi_string )
{
msg_Err( p_filter, "out of memory" );
goto error;
}
/* Do bidi conversion line-by-line */
while( pos < i_string_length )
......@@ -1218,10 +1206,7 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out,
/* Calculate relative glyph positions and a bounding box for the
* entire string */
if( !(p_line = NewLine( strlen( psz_string ))) )
{
msg_Err( p_filter, "out of memory" );
goto error;
}
p_lines = p_line;
i_pen_x = i_pen_y = 0;
i_previous = i = 0;
......@@ -1242,10 +1227,7 @@ static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out,
{
psz_line_start = psz_unicode;
if( !(p_next = NewLine( strlen( psz_string ))) )
{
msg_Err( p_filter, "out of memory" );
goto error;
}
p_line->p_next = p_next;
p_line->i_width = line.xMax;
p_line->i_height = face->size->metrics.height >> 6;
......@@ -2285,7 +2267,6 @@ static int ProcessLines( filter_t *p_filter,
! p_new_positions ||
! p_levels )
{
msg_Err( p_filter, "out of memory" );
free( p_levels );
free( p_old_positions );
free( p_new_positions );
......@@ -2500,7 +2481,6 @@ static int ProcessLines( filter_t *p_filter,
malloc( (k - i_prev + 1) * sizeof( uint32_t ));
if( !psz_unicode )
{
msg_Err( p_filter, "out of memory" );
if( p_face ) FT_Done_Face( p_face );
free( pp_char_styles );
free( psz_unicode );
......@@ -2519,7 +2499,6 @@ static int ProcessLines( filter_t *p_filter,
{
if( !(p_line = NewLine( i_len - i_prev)) )
{
msg_Err( p_filter, "out of memory" );
if( p_face ) FT_Done_Face( p_face );
free( pp_char_styles );
free( psz_unicode );
......
......@@ -167,10 +167,7 @@ static int Open( vlc_object_t *p_this )
/* Allocate instance and initialize some members */
p_intf->p_sys = (intf_sys_t *)malloc( sizeof( intf_sys_t ) );
if( p_intf->p_sys == NULL )
{
msg_Err( p_intf, "out of memory" );
return -1;
}
psz_mode = var_CreateGetString( p_intf, "logmode" );
if( psz_mode )
......
......@@ -142,10 +142,7 @@ static int Create( vlc_object_t *p_this )
// Allocate structure
p_filter->p_sys = p_sys = malloc( sizeof( filter_sys_t ) );
if( !p_sys )
{
msg_Err( p_filter, "out of memory" );
return VLC_ENOMEM;
}
p_sys->psz_font_name = strdup( DEFAULT_FONT );
p_sys->i_font_opacity = 255;
p_sys->i_font_color = DEFAULT_FONT_COLOR;
......
......@@ -365,10 +365,7 @@ static vod_media_t *MediaNew( vod_t *p_vod, const char *psz_name,
int i;
if( !p_media )
{
msg_Err( p_vod, "not enough memory" );
return NULL;
}
memset( p_media, 0, sizeof(vod_media_t) );
p_media->id = p_sys->i_media_id++;
......
......@@ -178,10 +178,8 @@ static xml_reader_t *ReaderCreate( xml_t *p_xml, stream_t *s )
/* Open and read file */
p_buffer = malloc( i_buffer );
if( p_buffer == NULL ) {
msg_Err( p_xml, "out of memory" );
if( p_buffer == NULL )
return NULL;
}
while( ( i_size = stream_Read( s, &p_buffer[i_pos], 2048 ) ) == 2048 )
{
......@@ -190,7 +188,6 @@ static xml_reader_t *ReaderCreate( xml_t *p_xml, stream_t *s )
p_new = realloc( p_buffer, i_buffer );
if( !p_new )
{
msg_Err( p_xml, "out of memory" );
free( p_buffer );
return NULL;
}
......
......@@ -739,10 +739,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
id = malloc( sizeof( sout_stream_id_t ) );
if( !id )
{
msg_Err( p_stream, "out of memory" );
goto error;
}
memset( id, 0, sizeof(sout_stream_id_t) );
id->id = NULL;
......@@ -752,10 +749,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
/* Create decoder object */
id->p_decoder = vlc_object_create( p_stream, VLC_OBJECT_DECODER );
if( !id->p_decoder )
{
msg_Err( p_stream, "out of memory" );
goto error;
}
vlc_object_attach( id->p_decoder, p_stream );
id->p_decoder->p_module = NULL;
id->p_decoder->fmt_in = *p_fmt;
......@@ -764,10 +758,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
/* Create encoder object */
id->p_encoder = vlc_object_create( p_stream, VLC_OBJECT_ENCODER );
if( !id->p_encoder )
{
msg_Err( p_stream, "out of memory" );
goto error;
}
vlc_object_attach( id->p_encoder, p_stream );
id->p_encoder->p_module = NULL;
......@@ -931,23 +922,26 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
return id;
error:
if( id->p_decoder )
error:
if( id )
{
vlc_object_detach( id->p_decoder );
vlc_object_release( id->p_decoder );
id->p_decoder = NULL;
}
if( id->p_decoder )
{
vlc_object_detach( id->p_decoder );
vlc_object_release( id->p_decoder );
id->p_decoder = NULL;
}
if( id->p_encoder )
{
vlc_object_detach( id->p_encoder );
es_format_Clean( &id->p_encoder->fmt_out );
vlc_object_release( id->p_encoder );
id->p_encoder = NULL;
}
if( id->p_encoder )
{
vlc_object_detach( id->p_encoder );
es_format_Clean( &id->p_encoder->fmt_out );
vlc_object_release( id->p_encoder );
id->p_encoder = NULL;
}
free( id );
free( id );
}
return NULL;
}
......
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