]> git.sesse.net Git - vlc/commitdiff
Remove msg_Err about memory allocation.
authorRémi Duraffort <ivoire@videolan.org>
Thu, 19 Jun 2008 17:57:09 +0000 (19:57 +0200)
committerRémi Duraffort <ivoire@videolan.org>
Thu, 19 Jun 2008 18:06:55 +0000 (20:06 +0200)
Fix two potential segfaults.
Cosmetics.

25 files changed:
src/audio_output/dec.c
src/audio_output/filters.c
src/audio_output/mixer.c
src/input/decoder.c
src/input/decoder_synchro.c
src/input/demux.c
src/input/input.c
src/input/stream.c
src/input/vlm.c
src/interface/interface.c
src/libvlc.c
src/misc/devices.c
src/misc/events.c
src/misc/image.c
src/misc/update.c
src/modules/modules.c
src/network/httpd.c
src/osd/osd.c
src/playlist/engine.c
src/playlist/loadsave.c
src/playlist/services_discovery.c
src/stream_output/announce.c
src/stream_output/sap.c
src/stream_output/stream_output.c
src/video_output/video_output.c

index 67a1d84748a93ca34b9972c942d40d3b50947f76..5c15891460cdad0edfba0cce46883589f9bc649b 100644 (file)
@@ -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 );
index de89d314462628c933fc07d80a2743ac912eae80..5a2ffad6cb18c93c95f80a1fab60968b60e65343 100644 (file)
@@ -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. */
 
index a1bc8bc5c69d73350b2638c9f10e3af5049836ad..0e73a2109cffcc7fa952073e01fc76e6999e88b5 100644 (file)
@@ -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;
     }
index aa715e96e2177c947b42d0a2711a121f33246731..45e2e784f4c6394a56437c290a754887b4b40ce3 100644 (file)
@@ -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;
index cfa67d8cf903e9bb18766c676b943d0a1c572ca9..f28aea476921305b37cf9069d09472996ddd9aa5 100644 (file)
@@ -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;
index 26bdc36845f31c73240193945c16532392da3668..be8f48e869dc4dcd6f6542a015c310fc4680b4d3 100644 (file)
@@ -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;
     }
index b70115d5e950b755bc0b61b2e1037d185497f86a..ace3b8264ab97864869a1ba77d5b0616e3647d77 100644 (file)
@@ -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];
index 48174e7b8544f287539a73f636696ea3ba754909..b469a901402948e40635d161ee10c7d364d5fb0b 100644 (file)
@@ -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;
index a9202b714eb87edeed339698d42ba5173ccf0c27..c239fde67997df23a4ffe5e2ba9eff02771ec0c7 100644 (file)
@@ -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 )
index 84a75d7c91e262d2e1a48886657f929f659394f5..cfbea2fb6995cfb455c2aaf60f246ecbe14ef273 100644 (file)
@@ -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;
index 24e391319d607d3f26f61c618b23e52c30829903..af2f813eb78cb74f671fa2641a7db26cd2f37384 100644 (file)
@@ -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 );
index e779226af9bb36c90236e9cdb7ca18b9c341e918..e6241c8d473f6520560257fd1f5b609363ddc31b 100644 (file)
@@ -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 )
     {
index 19893353536b5f5ffb93417e19364e1165353cc3..089b5e85f87a82f08d261d8597fdc46f390425d5 100644 (file)
@@ -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;
             }
index 1690ff82cf71b8fb0ba6cb247b98cbb82486a6f9..aa8a30152a8db0f010c9cf25f1c6e73e73aa1ba8 100644 (file)
@@ -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 );
index 1b7e54cbe4f1234e17b5cc71647d94a526e1f500..6d25a22aa128ac9273a0a95d4f1fa5b8a3be4e6e 100644 (file)
@@ -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;
index cfc313a1596988608feaf554a430d71c0e88bddb..8301933064113eacf4249e81c545d239675bcdd9 100644 (file)
@@ -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 )
index 8fdf75e9851ed8d0a94c6c377c5824a001fa4b71..35fb1959e18a8389295b8073378d722a2a277ec1 100644 (file)
@@ -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 );
index adc1c510e22e985a748fa4d4b590d339a8d4f73c..b36d4a5a6a5a6206118b7ea56b935e50242fcd06 100644 (file)
@@ -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 );
 
index 8b23bc73d21d37293afc1d034440bd51990e7a7e..7ae4cc3e786038dff071e9887be91783ba0a1eec 100644 (file)
@@ -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 );
 
index 85eda590f0b8d5be34e50131e1f77db60e8bb3f7..64b44b8333de3071136617489e7d7bdebeaa13f8 100644 (file)
@@ -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 );
index 4fb9ea3f43e1c768d3989308ba9f7a8cdda3adf8..a08535287e0c63b8ba44f963be4cad97129da82a 100644 (file)
@@ -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;
index 3a723e360558c6c9e75d3b0bac52a85e50d9f147..7dedc1e0508c412716c6c08213d29f5bd8243f11 100644 (file)
@@ -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);
index 70b078da9aedc88613d57d59e80afbbb3bcbd1b2..49b1c9f9feb7ab484f038401365d2a4b0f240665 100644 (file)
@@ -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" );
 
index 30304d9e401f163745ec3c4c7864a41acd4a23fc..f52c017c001e06e2920d13589831da500be28149 100644 (file)
@@ -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;
index 6be0dbc9be5096a0de59bd4ba9b464160e59ff26..d2be65a4a8ea1db608b2f06ee09c00f5d0443ee5 100644 (file)
@@ -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;