Commit f864df7f authored by Antoine Cellerier's avatar Antoine Cellerier

psz_object_name should not be const! (else module name aliasing cannot work)

parent e8e2bcf0
...@@ -523,7 +523,7 @@ typedef struct vlc_object_internals_t vlc_object_internals_t; ...@@ -523,7 +523,7 @@ typedef struct vlc_object_internals_t vlc_object_internals_t;
int i_object_id; \ int i_object_id; \
int i_object_type; \ int i_object_type; \
const char *psz_object_type; \ const char *psz_object_type; \
const char *psz_object_name; \ char *psz_object_name; \
\ \
/* Messages header */ \ /* Messages header */ \
char *psz_header; \ char *psz_header; \
......
...@@ -386,7 +386,7 @@ static int Create( vlc_object_t *p_this ) ...@@ -386,7 +386,7 @@ static int Create( vlc_object_t *p_this )
VLC_OBJECT_GENERIC ); VLC_OBJECT_GENERIC );
if( p_fontbuilder ) if( p_fontbuilder )
{ {
p_fontbuilder->psz_object_name = "fontlist builder"; p_fontbuilder->psz_object_name = strdup( "fontlist builder" );
vlc_object_attach( p_fontbuilder, p_filter->p_libvlc ); vlc_object_attach( p_fontbuilder, p_filter->p_libvlc );
var_Create( p_fontbuilder, "build-done", VLC_VAR_BOOL ); var_Create( p_fontbuilder, "build-done", VLC_VAR_BOOL );
......
...@@ -187,7 +187,7 @@ libvlc_int_t * libvlc_InternalCreate( void ) ...@@ -187,7 +187,7 @@ libvlc_int_t * libvlc_InternalCreate( void )
p_libvlc->p_playlist = NULL; p_libvlc->p_playlist = NULL;
p_libvlc->p_interaction = NULL; p_libvlc->p_interaction = NULL;
p_libvlc->p_vlm = NULL; p_libvlc->p_vlm = NULL;
p_libvlc->psz_object_name = "libvlc"; p_libvlc->psz_object_name = strdup( "libvlc" );
/* Initialize message queue */ /* Initialize message queue */
msg_Create( p_libvlc ); msg_Create( p_libvlc );
...@@ -254,16 +254,18 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -254,16 +254,18 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
/* Get the executable name (similar to the basename command) */ /* Get the executable name (similar to the basename command) */
if( i_argc > 0 ) if( i_argc > 0 )
{ {
const char *exe = p_libvlc->psz_object_name = ppsz_argv[0]; const char *exe = strdup( ppsz_argv[0] );
const char *tmp = exe;
while( *exe ) while( *exe )
{ {
if( *exe++ == '/' ) if( *exe++ == '/' )
p_libvlc->psz_object_name = exe; tmp = exe;
} }
p_libvlc->psz_object_name = strdup( tmp );
} }
else else
{ {
p_libvlc->psz_object_name = "vlc"; p_libvlc->psz_object_name = strdup( "vlc" );
} }
/* /*
......
...@@ -427,6 +427,8 @@ static void vlc_object_destroy( vlc_object_t *p_this ) ...@@ -427,6 +427,8 @@ static void vlc_object_destroy( vlc_object_t *p_this )
vlc_mutex_destroy( &structure_lock ); vlc_mutex_destroy( &structure_lock );
} }
FREENULL( p_this->psz_object_name );
#if defined(WIN32) || defined(UNDER_CE) #if defined(WIN32) || defined(UNDER_CE)
/* if object has an associated thread, close it now */ /* if object has an associated thread, close it now */
if( p_priv->thread_id.hThread ) if( p_priv->thread_id.hThread )
......
...@@ -41,7 +41,8 @@ module_t *vlc_module_create (vlc_object_t *obj) ...@@ -41,7 +41,8 @@ module_t *vlc_module_create (vlc_object_t *obj)
return NULL; return NULL;
module->b_reentrant = module->b_unloadable = true; module->b_reentrant = module->b_unloadable = true;
module->psz_object_name = module->psz_longname = default_name; module->psz_object_name = strdup( default_name );
module->psz_longname = default_name;
module->psz_capability = (char*)""; module->psz_capability = (char*)"";
module->i_score = 1; module->i_score = 1;
module->i_config_items = module->i_bool_items = 0; module->i_config_items = module->i_bool_items = 0;
...@@ -68,7 +69,7 @@ module_t *vlc_submodule_create (module_t *module) ...@@ -68,7 +69,7 @@ module_t *vlc_submodule_create (module_t *module)
memcpy (submodule->pp_shortcuts, module->pp_shortcuts, memcpy (submodule->pp_shortcuts, module->pp_shortcuts,
sizeof (submodule->pp_shortcuts)); sizeof (submodule->pp_shortcuts));
submodule->psz_object_name = module->psz_object_name; submodule->psz_object_name = strdup( module->psz_object_name );
submodule->psz_shortname = module->psz_shortname; submodule->psz_shortname = module->psz_shortname;
submodule->psz_longname = module->psz_longname; submodule->psz_longname = module->psz_longname;
submodule->psz_capability = module->psz_capability; submodule->psz_capability = module->psz_capability;
...@@ -131,7 +132,9 @@ int vlc_module_set (module_t *module, int propid, void *value) ...@@ -131,7 +132,9 @@ int vlc_module_set (module_t *module, int propid, void *value)
break; break;
case VLC_MODULE_NAME: case VLC_MODULE_NAME:
module->pp_shortcuts[0] = module->psz_object_name = (char *)value; free( module->psz_object_name );
module->psz_object_name = strdup( (char *)value );
module->pp_shortcuts[0] = (char *)value;
if (module->psz_longname == default_name) if (module->psz_longname == default_name)
module->psz_longname = (char *)value; module->psz_longname = (char *)value;
break; break;
......
...@@ -123,7 +123,7 @@ void __module_InitBank( vlc_object_t *p_this ) ...@@ -123,7 +123,7 @@ void __module_InitBank( vlc_object_t *p_this )
if( p_libvlc_global->p_module_bank == NULL ) if( p_libvlc_global->p_module_bank == NULL )
{ {
p_bank = vlc_object_create( p_this, sizeof(module_bank_t) ); p_bank = vlc_object_create( p_this, sizeof(module_bank_t) );
p_bank->psz_object_name = "module bank"; p_bank->psz_object_name = strdup( "module bank" );
p_bank->i_usage = 1; p_bank->i_usage = 1;
p_bank->i_cache = p_bank->i_loaded_cache = 0; p_bank->i_cache = p_bank->i_loaded_cache = 0;
p_bank->pp_cache = p_bank->pp_loaded_cache = NULL; p_bank->pp_cache = p_bank->pp_loaded_cache = NULL;
...@@ -1314,7 +1314,6 @@ static void DupModule( module_t *p_module ) ...@@ -1314,7 +1314,6 @@ static void DupModule( module_t *p_module )
/* We strdup() these entries so that they are still valid when the /* We strdup() these entries so that they are still valid when the
* module is unloaded. */ * module is unloaded. */
/* This one is a (const char *) that will never get freed. */
p_module->psz_object_name = strdup( p_module->psz_object_name ); p_module->psz_object_name = strdup( p_module->psz_object_name );
p_module->psz_capability = strdup( p_module->psz_capability ); p_module->psz_capability = strdup( p_module->psz_capability );
p_module->psz_shortname = p_module->psz_shortname ? p_module->psz_shortname = p_module->psz_shortname ?
...@@ -1349,7 +1348,7 @@ static void UndupModule( module_t *p_module ) ...@@ -1349,7 +1348,7 @@ static void UndupModule( module_t *p_module )
free( *pp_shortcut ); free( *pp_shortcut );
} }
free( p_module->psz_object_name ); FREENULL( p_module->psz_object_name );
free( p_module->psz_capability ); free( p_module->psz_capability );
free( p_module->psz_shortname ); free( p_module->psz_shortname );
free( p_module->psz_longname ); free( p_module->psz_longname );
......
...@@ -61,7 +61,7 @@ void __playlist_ThreadCreate( vlc_object_t *p_parent ) ...@@ -61,7 +61,7 @@ void __playlist_ThreadCreate( vlc_object_t *p_parent )
// Preparse // Preparse
p_playlist->p_preparse = vlc_object_create( p_playlist, p_playlist->p_preparse = vlc_object_create( p_playlist,
sizeof( playlist_preparse_t ) ); sizeof( playlist_preparse_t ) );
p_playlist->p_preparse->psz_object_name = "preparser"; p_playlist->p_preparse->psz_object_name = strdup( "preparser" );
if( !p_playlist->p_preparse ) if( !p_playlist->p_preparse )
{ {
msg_Err( p_playlist, "unable to create preparser" ); msg_Err( p_playlist, "unable to create preparser" );
...@@ -85,7 +85,7 @@ void __playlist_ThreadCreate( vlc_object_t *p_parent ) ...@@ -85,7 +85,7 @@ void __playlist_ThreadCreate( vlc_object_t *p_parent )
// Secondary Preparse // Secondary Preparse
p_playlist->p_fetcher = vlc_object_create( p_playlist, p_playlist->p_fetcher = vlc_object_create( p_playlist,
sizeof( playlist_fetcher_t ) ); sizeof( playlist_fetcher_t ) );
p_playlist->p_fetcher->psz_object_name = "fetcher"; p_playlist->p_fetcher->psz_object_name = strdup( "fetcher" );
if( !p_playlist->p_fetcher ) if( !p_playlist->p_fetcher )
{ {
msg_Err( p_playlist, "unable to create secondary preparser" ); msg_Err( p_playlist, "unable to create secondary preparser" );
......
...@@ -128,7 +128,7 @@ sap_handler_t *announce_SAPHandlerCreate( announce_handler_t *p_announce ) ...@@ -128,7 +128,7 @@ sap_handler_t *announce_SAPHandlerCreate( announce_handler_t *p_announce )
return NULL; return NULL;
} }
p_sap->psz_object_name = "sap announcer"; p_sap->psz_object_name = strdup( "sap announcer" );
vlc_mutex_init( p_sap, &p_sap->object_lock ); vlc_mutex_init( p_sap, &p_sap->object_lock );
......
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