Commit 57c3ecd2 authored by Rémi Duraffort's avatar Rémi Duraffort

Remove msg_Err about memory allocation.

Fix two potential segfaults.
Cosmetics.
parent ec300ad9
......@@ -79,10 +79,7 @@ static aout_input_t * DecNew( vlc_object_t * p_this, aout_instance_t * p_aout,
p_input = malloc(sizeof(aout_input_t));
if ( p_input == NULL )
{
msg_Err( p_aout, "out of memory" );
goto error;
}
memset( p_input, 0, sizeof(aout_input_t) );
vlc_mutex_init( &p_input->lock );
......
......@@ -343,10 +343,7 @@ void aout_FiltersPlay( aout_instance_t * p_aout,
* 1000000 / p_filter->input.i_rate,
*pp_input_buffer, p_output_buffer );
if ( p_output_buffer == NULL )
{
msg_Err( p_aout, "out of memory" );
return;
}
/* Please note that p_output_buffer->i_nb_samples & i_nb_bytes
* shall be set by the filter plug-in. */
......
......@@ -314,7 +314,6 @@ static int MixBuffer( aout_instance_t * p_aout )
p_output_buffer );
if ( p_output_buffer == NULL )
{
msg_Err( p_aout, "out of memory" );
vlc_mutex_unlock( &p_aout->input_fifos_lock );
return -1;
}
......
......@@ -445,10 +445,7 @@ static decoder_t * CreateDecoder( input_thread_t *p_input,
p_dec = vlc_object_create( p_input, i_object_type );
if( p_dec == NULL )
{
msg_Err( p_input, "out of memory" );
return NULL;
}
p_dec->pf_decode_audio = 0;
p_dec->pf_decode_video = 0;
......@@ -466,10 +463,7 @@ static decoder_t * CreateDecoder( input_thread_t *p_input,
/* Allocate our private structure for the decoder */
p_dec->p_owner = p_owner = malloc( sizeof( decoder_owner_sys_t ) );
if( p_dec->p_owner == NULL )
{
msg_Err( p_dec, "out of memory" );
return NULL;
}
p_dec->p_owner->b_own_thread = true;
p_dec->p_owner->i_preroll_end = -1;
p_dec->p_owner->p_input = p_input;
......@@ -484,10 +478,7 @@ static decoder_t * CreateDecoder( input_thread_t *p_input,
/* decoder fifo */
if( ( p_dec->p_owner->p_fifo = block_FifoNew() ) == NULL )
{
msg_Err( p_dec, "out of memory" );
return NULL;
}
/* Set buffers allocation callbacks for the decoders */
p_dec->pf_aout_buffer_new = aout_new_buffer;
......
......@@ -164,10 +164,7 @@ decoder_synchro_t * decoder_SynchroInit( decoder_t *p_dec, int i_frame_rate )
{
decoder_synchro_t * p_synchro = malloc( sizeof(*p_synchro) );
if ( p_synchro == NULL )
{
msg_Err( p_dec, "out of memory" );
return NULL;
}
memset( p_synchro, 0, sizeof(*p_synchro) );
p_synchro->p_dec = p_dec;
......
......@@ -322,6 +322,8 @@ stream_t *__stream_DemuxNew( vlc_object_t *p_obj, const char *psz_demux,
if( psz_demux == NULL || *psz_demux == '\0' ) return NULL;
s = vlc_stream_create( p_obj );
if( s == NULL )
return NULL;
s->pf_read = DStreamRead;
s->pf_peek = DStreamPeek;
s->pf_control= DStreamControl;
......@@ -330,6 +332,11 @@ stream_t *__stream_DemuxNew( vlc_object_t *p_obj, const char *psz_demux,
s->b_little_endian = false;
s->p_sys = malloc( sizeof( d_stream_sys_t) );
if( s->p_sys == NULL )
{
vlc_object_release( s );
return NULL;
}
p_sys = (d_stream_sys_t*)s->p_sys;
p_sys->i_pos = 0;
......@@ -341,8 +348,8 @@ stream_t *__stream_DemuxNew( vlc_object_t *p_obj, const char *psz_demux,
/* decoder fifo */
if( ( p_sys->p_fifo = block_FifoNew() ) == NULL )
{
msg_Err( s, "out of memory" );
vlc_object_release( s );
free( p_sys->psz_name );
free( p_sys );
return NULL;
}
......
......@@ -131,10 +131,7 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
p_input = vlc_custom_create( p_parent, sizeof( *p_input ),
VLC_OBJECT_INPUT, input_name );
if( p_input == NULL )
{
msg_Err( p_parent, "out of memory" );
return NULL;
}
/* Construct a nice name for the input timer */
char psz_timer_name[255];
......
......@@ -297,10 +297,7 @@ stream_t *stream_AccessNew( access_t *p_access, bool b_quick )
s->p_sys = p_sys = malloc( sizeof( stream_sys_t ) );
if( p_sys == NULL )
{
msg_Err( s, "Out of memory when allocating stream_sys_t" );
goto error;
}
/* UTF16 and UTF32 text file conversion */
s->i_char_width = 1;
......@@ -338,10 +335,7 @@ stream_t *stream_AccessNew( access_t *p_access, bool b_quick )
{
access_entry_t *p_entry = malloc( sizeof(access_entry_t) );
if( p_entry == NULL )
{
msg_Err( s, "Out of memory when allocating access_entry_t" );
goto error;
}
char *psz_name, *psz_parser = psz_name = psz_list;
p_sys->p_list_access = p_access;
......@@ -349,7 +343,6 @@ stream_t *stream_AccessNew( access_t *p_access, bool b_quick )
p_entry->psz_path = strdup( p_access->psz_path );
if( p_entry->psz_path == NULL )
{
msg_Err( s, "Out of memory when duplicating p_access->psz_path" );
free( p_entry );
goto error;
}
......@@ -380,10 +373,7 @@ stream_t *stream_AccessNew( access_t *p_access, bool b_quick )
p_entry = malloc( sizeof(access_entry_t) );
if( p_entry == NULL )
{
msg_Err( p_access, "Out of memory when allocating access_entry_t" );
goto error;
}
p_entry->i_size = p_tmp->info.i_size;
p_entry->psz_path = psz_name;
TAB_APPEND( p_sys->i_list, p_sys->list, p_entry );
......@@ -1793,10 +1783,7 @@ char * stream_ReadLine( stream_t *s )
i_data = (psz_eol - (char *)p_data) + 1;
p_line = realloc( p_line, i_line + i_data + s->i_char_width ); /* add \0 */
if( !p_line )
{
msg_Err( s, "Out of memory when reallocating p_line" );
goto error;
}
i_data = stream_Read( s, &p_line[i_line], i_data );
if( i_data <= 0 ) break; /* Hmmm */
i_line += i_data - s->i_char_width; /* skip \n */;
......@@ -1809,10 +1796,7 @@ char * stream_ReadLine( stream_t *s )
/* Read data (+1 for easy \0 append) */
p_line = realloc( p_line, i_line + STREAM_PROBE_LINE + s->i_char_width );
if( !p_line )
{
msg_Err( s, "Out of memory when reallocating p_line" );
goto error;
}
i_data = stream_Read( s, &p_line[i_line], STREAM_PROBE_LINE );
if( i_data <= 0 ) break; /* Hmmm */
i_line += i_data;
......@@ -1837,10 +1821,7 @@ char * stream_ReadLine( stream_t *s )
/* iconv */
psz_new_line = malloc( i_line );
if( psz_new_line == NULL )
{
msg_Err( s, "Out of memory when allocating psz_new_line" );
goto error;
}
i_in = i_out = (size_t)i_line;
p_in = p_line;
p_out = psz_new_line;
......
......@@ -616,10 +616,7 @@ static int vlm_ControlMediaAdd( vlm_t *p_vlm, vlm_media_t *p_cfg, int64_t *p_id
p_media = malloc( sizeof( vlm_media_sys_t ) );
if( !p_media )
{
msg_Err( p_vlm, "out of memory" );
return VLC_ENOMEM;
}
memset( p_media, 0, sizeof(vlm_media_sys_t) );
if( p_cfg->b_vod )
......
......@@ -92,10 +92,7 @@ intf_thread_t* __intf_Create( vlc_object_t *p_this, const char *psz_module )
/* Allocate structure */
p_intf = vlc_object_create( p_this, VLC_OBJECT_INTF );
if( !p_intf )
{
msg_Err( p_this, "out of memory" );
return NULL;
}
p_intf->pf_request_window = NULL;
p_intf->pf_release_window = NULL;
p_intf->pf_control_window = NULL;
......
......@@ -577,7 +577,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
if ( !dbus_message_iter_append_basic( &dbus_args,
DBUS_TYPE_STRING, &ppsz_argv[i_input] ) )
{
msg_Err( p_libvlc, "Out of memory" );
dbus_message_unref( p_dbus_msg );
system_End( p_libvlc );
exit( VLC_ENOMEM );
......@@ -588,7 +587,6 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
if ( !dbus_message_iter_append_basic( &dbus_args,
DBUS_TYPE_BOOLEAN, &b_play ) )
{
msg_Err( p_libvlc, "Out of memory" );
dbus_message_unref( p_dbus_msg );
system_End( p_libvlc );
exit( VLC_ENOMEM );
......
......@@ -43,10 +43,7 @@ void devices_ProbeCreate( vlc_object_t *p_this )
/* Allocate structure */
p_probe = vlc_object_create( p_this, VLC_OBJECT_INTF );
if( !p_probe )
{
msg_Err( p_this, "out of memory" );
return;
}
p_probe->p_module = module_Need( p_probe, "devices probe", "", false );
if( p_probe->p_module == NULL )
{
......
......@@ -210,7 +210,6 @@ void vlc_event_send( vlc_event_manager_t * p_em,
sizeof(vlc_event_listener_t)*i_cached_listeners );
if( !array_of_cached_listeners )
{
msg_Err( p_em->p_parent_object, "Not enough memory in vlc_event_send" );
vlc_mutex_unlock( &p_em->object_lock );
return;
}
......
......@@ -620,10 +620,7 @@ static decoder_t *CreateDecoder( vlc_object_t *p_this, video_format_t *fmt )
p_dec = vlc_object_create( p_this, VLC_OBJECT_DECODER );
if( p_dec == NULL )
{
msg_Err( p_this, "out of memory" );
return NULL;
}
p_dec->p_module = NULL;
es_format_Init( &p_dec->fmt_in, VIDEO_ES, fmt->i_chroma );
......@@ -673,10 +670,7 @@ static encoder_t *CreateEncoder( vlc_object_t *p_this, video_format_t *fmt_in,
p_enc = vlc_object_create( p_this, VLC_OBJECT_ENCODER );
if( p_enc == NULL )
{
msg_Err( p_this, "out of memory" );
return NULL;
}
p_enc->p_module = NULL;
es_format_Init( &p_enc->fmt_in, VIDEO_ES, fmt_in->i_chroma );
......
......@@ -1452,10 +1452,7 @@ void update_Download( update_t *p_update, const char *psz_destdir )
update_download_thread_t *p_udt = vlc_object_create( p_update->p_libvlc,
sizeof( update_download_thread_t ) );
if( !p_udt )
{
msg_Err( p_update->p_libvlc, "out of memory" );
return;
}
p_udt->p_update = p_update;
p_udt->psz_destdir = psz_destdir ? strdup( psz_destdir ) : NULL;
......
......@@ -1245,7 +1245,6 @@ static module_t * AllocatePlugin( vlc_object_t * p_this, char * psz_file )
p_module = vlc_module_create( p_this );
if( p_module == NULL )
{
msg_Err( p_this, "out of memory" );
module_Unload( handle );
return NULL;
}
......@@ -1349,10 +1348,7 @@ static int AllocateBuiltinModule( vlc_object_t * p_this,
* allocate a structure for it */
p_module = vlc_module_create( p_this );
if( p_module == NULL )
{
msg_Err( p_this, "out of memory" );
return -1;
}
/* Initialize the module : fill p_module->psz_object_name, etc. */
if( pf_entry( p_module ) != 0 )
......
......@@ -989,10 +989,7 @@ httpd_host_t *httpd_TLSHostNew( vlc_object_t *p_this, const char *psz_hostname,
psz_host = strdup( psz_hostname );
if( psz_host == NULL )
{
msg_Err( p_this, "memory error" );
return NULL;
}
/* to be sure to avoid multiple creation */
var_Create( p_this->p_libvlc, "httpd_mutex", VLC_VAR_MUTEX );
......
......@@ -72,10 +72,7 @@ static osd_menu_t *osd_ParserLoad( vlc_object_t *p_this, const char *psz_file )
p_menu = vlc_custom_create( p_this, sizeof( *p_menu ), VLC_OBJECT_OSDMENU,
osdmenu_name );
if( !p_menu )
{
msg_Err( p_this, "out of memory" );
return NULL;
}
vlc_object_yield( p_menu );
vlc_object_attach( p_menu, p_this->p_libvlc );
......
......@@ -68,10 +68,7 @@ playlist_t * playlist_Create( vlc_object_t *p_parent )
p_playlist = vlc_custom_create( p_parent, sizeof( *p_playlist ),
VLC_OBJECT_GENERIC, playlist_name );
if( !p_playlist )
{
msg_Err( p_parent, "out of memory" );
return NULL;
}
TAB_INIT( p_playlist->i_sds, p_playlist->pp_sds );
......
......@@ -50,10 +50,7 @@ int playlist_Export( playlist_t * p_playlist, const char *psz_filename ,
/* Prepare the playlist_export_t structure */
p_export = (playlist_export_t *)malloc( sizeof(playlist_export_t) );
if( !p_export)
{
msg_Err( p_playlist, "out of memory" );
return VLC_ENOMEM;
}
p_export->psz_filename = NULL;
if ( psz_filename )
p_export->psz_filename = strdup( psz_filename );
......
......@@ -335,10 +335,7 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_modu
/* Free in playlist_ServicesDiscoveryRemove */
p_sds = malloc( sizeof(struct playlist_services_discovery_support_t) );
if( !p_sds )
{
msg_Err( p_playlist, "No more memory" );
return VLC_ENOMEM;
}
p_sds->p_sd = p_sd;
p_sds->p_one = p_one;
p_sds->p_cat = p_cat;
......
......@@ -159,10 +159,7 @@ static announce_handler_t *announce_HandlerCreate( vlc_object_t *p_this )
p_announce = vlc_object_create( p_this, VLC_OBJECT_ANNOUNCE );
if( !p_announce )
{
msg_Err( p_this, "out of memory" );
return NULL;
}
p_announce->p_sap = NULL;
vlc_object_attach( p_announce, p_this->p_libvlc);
......
......@@ -123,10 +123,7 @@ sap_handler_t *announce_SAPHandlerCreate( announce_handler_t *p_announce )
p_sap = vlc_custom_create( VLC_OBJECT(p_announce), sizeof( sap_handler_t ),
VLC_OBJECT_ANNOUNCE, "announce" );
if( !p_sap )
{
msg_Err( p_announce, "out of memory" );
return NULL;
}
p_sap->psz_object_name = strdup( "sap announcer" );
......
......@@ -299,17 +299,14 @@ sout_access_out_t *sout_AccessOutNew( sout_instance_t *p_sout,
if( !( p_access = vlc_object_create( p_sout,
sizeof( sout_access_out_t ) ) ) )
{
msg_Err( p_sout, "out of memory" );
return NULL;
}
psz_next = config_ChainCreate( &p_access->psz_access, &p_access->p_cfg,
psz_access );
free( psz_next );
p_access->psz_path = strdup( psz_name ? psz_name : "" );
p_access->p_sout = p_sout;
p_access->p_sys = NULL;
p_access->p_sys = NULL;
p_access->pf_seek = NULL;
p_access->pf_read = NULL;
p_access->pf_write = NULL;
......@@ -408,10 +405,7 @@ sout_mux_t * sout_MuxNew( sout_instance_t *p_sout, char *psz_mux,
p_mux = vlc_object_create( p_sout, sizeof( sout_mux_t ) );
if( p_mux == NULL )
{
msg_Err( p_sout, "out of memory" );
return NULL;
}
p_mux->p_sout = p_sout;
psz_next = config_ChainCreate( &p_mux->psz_mux, &p_mux->p_cfg, psz_mux );
......@@ -523,10 +517,7 @@ sout_input_t *sout_MuxAddStream( sout_mux_t *p_mux, es_format_t *p_fmt )
/* create a new sout input */
p_input = malloc( sizeof( sout_input_t ) );
if( !p_input )
{
msg_Err( p_mux, "out of memory" );
return NULL;
}
p_input->p_sout = p_mux->p_sout;
p_input->p_fmt = p_fmt;
p_input->p_fifo = block_FifoNew();
......@@ -777,10 +768,7 @@ sout_stream_t *sout_StreamNew( sout_instance_t *p_sout, char *psz_chain )
p_stream = vlc_object_create( p_sout, sizeof( sout_stream_t ) );
if( !p_stream )
{
msg_Err( p_sout, "out of memory" );
return NULL;
}
p_stream->p_sout = p_sout;
p_stream->p_sys = NULL;
......
......@@ -443,7 +443,6 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt )
if( vlc_thread_create( p_vout, "video output", RunThread,
VLC_THREAD_PRIORITY_OUTPUT, true ) )
{
msg_Err( p_vout, "out of memory" );
module_Unneed( p_vout, p_vout->p_module );
vlc_object_release( p_vout );
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