From 57c3ecd2292588c7312afbb6935d414bfbe2e826 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Duraffort?= Date: Thu, 19 Jun 2008 19:57:09 +0200 Subject: [PATCH] Remove msg_Err about memory allocation. Fix two potential segfaults. Cosmetics. --- src/audio_output/dec.c | 3 --- src/audio_output/filters.c | 3 --- src/audio_output/mixer.c | 1 - src/input/decoder.c | 9 --------- src/input/decoder_synchro.c | 3 --- src/input/demux.c | 9 ++++++++- src/input/input.c | 3 --- src/input/stream.c | 19 ------------------- src/input/vlm.c | 3 --- src/interface/interface.c | 3 --- src/libvlc.c | 2 -- src/misc/devices.c | 3 --- src/misc/events.c | 1 - src/misc/image.c | 6 ------ src/misc/update.c | 3 --- src/modules/modules.c | 4 ---- src/network/httpd.c | 3 --- src/osd/osd.c | 3 --- src/playlist/engine.c | 3 --- src/playlist/loadsave.c | 3 --- src/playlist/services_discovery.c | 3 --- src/stream_output/announce.c | 3 --- src/stream_output/sap.c | 3 --- src/stream_output/stream_output.c | 14 +------------- src/video_output/video_output.c | 1 - 25 files changed, 9 insertions(+), 102 deletions(-) diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c index 67a1d84748..5c15891460 100644 --- a/src/audio_output/dec.c +++ b/src/audio_output/dec.c @@ -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 ); diff --git a/src/audio_output/filters.c b/src/audio_output/filters.c index de89d31446..5a2ffad6cb 100644 --- a/src/audio_output/filters.c +++ b/src/audio_output/filters.c @@ -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. */ diff --git a/src/audio_output/mixer.c b/src/audio_output/mixer.c index a1bc8bc5c6..0e73a2109c 100644 --- a/src/audio_output/mixer.c +++ b/src/audio_output/mixer.c @@ -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; } diff --git a/src/input/decoder.c b/src/input/decoder.c index aa715e96e2..45e2e784f4 100644 --- a/src/input/decoder.c +++ b/src/input/decoder.c @@ -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; diff --git a/src/input/decoder_synchro.c b/src/input/decoder_synchro.c index cfa67d8cf9..f28aea4769 100644 --- a/src/input/decoder_synchro.c +++ b/src/input/decoder_synchro.c @@ -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; diff --git a/src/input/demux.c b/src/input/demux.c index 26bdc36845..be8f48e869 100644 --- a/src/input/demux.c +++ b/src/input/demux.c @@ -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; } diff --git a/src/input/input.c b/src/input/input.c index b70115d5e9..ace3b8264a 100644 --- a/src/input/input.c +++ b/src/input/input.c @@ -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]; diff --git a/src/input/stream.c b/src/input/stream.c index 48174e7b85..b469a90140 100644 --- a/src/input/stream.c +++ b/src/input/stream.c @@ -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; diff --git a/src/input/vlm.c b/src/input/vlm.c index a9202b714e..c239fde679 100644 --- a/src/input/vlm.c +++ b/src/input/vlm.c @@ -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 ) diff --git a/src/interface/interface.c b/src/interface/interface.c index 84a75d7c91..cfbea2fb69 100644 --- a/src/interface/interface.c +++ b/src/interface/interface.c @@ -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; diff --git a/src/libvlc.c b/src/libvlc.c index 24e391319d..af2f813eb7 100644 --- a/src/libvlc.c +++ b/src/libvlc.c @@ -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 ); diff --git a/src/misc/devices.c b/src/misc/devices.c index e779226af9..e6241c8d47 100644 --- a/src/misc/devices.c +++ b/src/misc/devices.c @@ -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 ) { diff --git a/src/misc/events.c b/src/misc/events.c index 1989335353..089b5e85f8 100644 --- a/src/misc/events.c +++ b/src/misc/events.c @@ -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; } diff --git a/src/misc/image.c b/src/misc/image.c index 1690ff82cf..aa8a30152a 100644 --- a/src/misc/image.c +++ b/src/misc/image.c @@ -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 ); diff --git a/src/misc/update.c b/src/misc/update.c index 1b7e54cbe4..6d25a22aa1 100644 --- a/src/misc/update.c +++ b/src/misc/update.c @@ -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; diff --git a/src/modules/modules.c b/src/modules/modules.c index cfc313a159..8301933064 100644 --- a/src/modules/modules.c +++ b/src/modules/modules.c @@ -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 ) diff --git a/src/network/httpd.c b/src/network/httpd.c index 8fdf75e985..35fb1959e1 100644 --- a/src/network/httpd.c +++ b/src/network/httpd.c @@ -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 ); diff --git a/src/osd/osd.c b/src/osd/osd.c index adc1c510e2..b36d4a5a6a 100644 --- a/src/osd/osd.c +++ b/src/osd/osd.c @@ -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 ); diff --git a/src/playlist/engine.c b/src/playlist/engine.c index 8b23bc73d2..7ae4cc3e78 100644 --- a/src/playlist/engine.c +++ b/src/playlist/engine.c @@ -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 ); diff --git a/src/playlist/loadsave.c b/src/playlist/loadsave.c index 85eda590f0..64b44b8333 100644 --- a/src/playlist/loadsave.c +++ b/src/playlist/loadsave.c @@ -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 ); diff --git a/src/playlist/services_discovery.c b/src/playlist/services_discovery.c index 4fb9ea3f43..a08535287e 100644 --- a/src/playlist/services_discovery.c +++ b/src/playlist/services_discovery.c @@ -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; diff --git a/src/stream_output/announce.c b/src/stream_output/announce.c index 3a723e3605..7dedc1e050 100644 --- a/src/stream_output/announce.c +++ b/src/stream_output/announce.c @@ -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); diff --git a/src/stream_output/sap.c b/src/stream_output/sap.c index 70b078da9a..49b1c9f9fe 100644 --- a/src/stream_output/sap.c +++ b/src/stream_output/sap.c @@ -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" ); diff --git a/src/stream_output/stream_output.c b/src/stream_output/stream_output.c index 30304d9e40..f52c017c00 100644 --- a/src/stream_output/stream_output.c +++ b/src/stream_output/stream_output.c @@ -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; diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c index 6be0dbc9be..d2be65a4a8 100644 --- a/src/video_output/video_output.c +++ b/src/video_output/video_output.c @@ -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; -- 2.39.2