Commit aab3bb4e authored by Rafaël Carré's avatar Rafaël Carré

Simplify executable name retrieval and fix a memory leak

parent f83f9df3
...@@ -250,18 +250,21 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -250,18 +250,21 @@ 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 = ppsz_argv[0]; const char *psz_exe = ppsz_argv[0] + strlen( ppsz_argv[0] );
const char *tmp = exe; for( ; psz_exe > ppsz_argv[0] ; psz_exe-- )
while( *exe )
{ {
if( *exe++ == '/' ) if( *psz_exe == '/' )
tmp = exe; {
psz_exe++;
break;
}
}
if( *psz_exe )
{
free( p_libvlc->psz_object_name );
p_libvlc->psz_object_name = strdup( psz_exe );
} }
p_libvlc->psz_object_name = strdup( tmp );
}
else
{
p_libvlc->psz_object_name = strdup( "vlc" );
} }
/* /*
......
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