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,
/* Get the executable name (similar to the basename command) */
if( i_argc > 0 )
{
const char *exe = ppsz_argv[0];
const char *tmp = exe;
while( *exe )
const char *psz_exe = ppsz_argv[0] + strlen( ppsz_argv[0] );
for( ; psz_exe > ppsz_argv[0] ; psz_exe-- )
{
if( *exe++ == '/' )
tmp = exe;
if( *psz_exe == '/' )
{
psz_exe++;
break;
}
p_libvlc->psz_object_name = strdup( tmp );
}
else
if( *psz_exe )
{
p_libvlc->psz_object_name = strdup( "vlc" );
free( p_libvlc->psz_object_name );
p_libvlc->psz_object_name = strdup( psz_exe );
}
}
/*
......
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