Commit 49bca36d authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Use free() instead of LocaleFree() for utf8_readdir() result

parent e1e9924a
......@@ -40,7 +40,7 @@ VLC_EXPORT( char *, ToLocale, ( const char * ) );
VLC_EXPORT( int, utf8_open, ( const char *filename, int flags, mode_t mode ) );
VLC_EXPORT( FILE *, utf8_fopen, ( const char *filename, const char *mode ) );
VLC_EXPORT( void *, utf8_opendir, ( const char *dirname ) );
VLC_EXPORT( const char *, utf8_readdir, ( void *dir ) );
VLC_EXPORT( char *, utf8_readdir, ( void *dir ) );
VLC_EXPORT( int, utf8_scandir, ( const char *dirname, char ***namelist, int (*select)( const char * ), int (*compar)( const char **, const char ** ) ) );
VLC_EXPORT( int, utf8_stat, ( const char *filename, void *buf ) );
VLC_EXPORT( int, utf8_lstat, ( const char *filename, void *buf ) );
......
......@@ -468,7 +468,7 @@ struct module_symbols_t
void *vlc_HashRetrieve_deprecated;
void * (*utf8_opendir_inner) (const char *dirname);
FILE * (*utf8_fopen_inner) (const char *filename, const char *mode);
const char * (*utf8_readdir_inner) (void *dir);
char * (*utf8_readdir_inner) (void *dir);
int (*utf8_stat_inner) (const char *filename, void *buf);
int (*utf8_lstat_inner) (const char *filename, void *buf);
char * (*FromLocaleDup_inner) (const char *);
......
......@@ -206,7 +206,7 @@ int E_(ParseDirectory)( intf_thread_t *p_intf, char *psz_root,
continue;
sprintf( dir, "%s%c%s", psz_dir, sep, psz_filename );
LocaleFree( psz_filename );
free( psz_filename );
if( E_(ParseDirectory)( p_intf, psz_root, dir ) )
{
......
......@@ -1945,7 +1945,7 @@ static void ReadDir( intf_thread_t *p_intf )
( strlen( psz_entry ) && psz_entry[0] == '.' ) &&
strcmp( psz_entry, ".." ) )
{
LocaleFree( psz_entry );
free( psz_entry );
psz_entry = utf8_readdir( p_current_dir );
continue;
}
......@@ -1982,7 +1982,7 @@ static void ReadDir( intf_thread_t *p_intf )
}
free( psz_uri );
LocaleFree( psz_entry );
free( psz_entry );
/* Read next entry */
psz_entry = utf8_readdir( p_current_dir );
}
......
......@@ -504,13 +504,13 @@ gnutls_Addx509Directory( vlc_object_t *p_this,
char *psz_filename;
int check;
if( ( strcmp( ".", psz_dirent ) == 0 )
if( (psz_dirent == NULL)
|| ( strcmp( ".", psz_dirent ) == 0 )
|| ( strcmp( "..", psz_dirent ) == 0 ) )
continue;
check = asprintf( &psz_filename, "%s/%s", psz_dirname,
psz_dirent );
LocaleFree( psz_dirent );
check = asprintf( &psz_filename, "%s/%s", psz_dirname, psz_dirent );
free( psz_dirent );
if( check == -1 )
continue;
......
......@@ -470,7 +470,10 @@ void *utf8_opendir( const char *dirname )
return NULL;
}
const char *utf8_readdir( void *dir )
#define darwin_readdir_fix( a ) __vlc_fix_readdir_charset (NULL, a)
char *utf8_readdir( void *dir )
{
struct dirent *ent;
......@@ -478,7 +481,11 @@ const char *utf8_readdir( void *dir )
if( ent == NULL )
return NULL;
return FromLocale( ent->d_name );
#ifdef __APPLE__
return darwin_readdir_fix( ent->d_name );
#else
return strdup( ent->d_name );
#endif
}
static int dummy_select( const char *str )
......@@ -507,25 +514,21 @@ int utf8_scandir( const char *dirname, char ***namelist,
while( ( entry = utf8_readdir( dir ) ) != NULL )
{
char **newtab;
char *utf_entry = strdup( entry );
LocaleFree( entry );
if( utf_entry == NULL )
goto error;
if( !select( utf_entry ) )
if( !select( entry ) )
{
free( utf_entry );
free( entry );
continue;
}
newtab = realloc( tab, sizeof( char * ) * (num + 1) );
if( newtab == NULL )
{
free( utf_entry );
free( entry );
goto error;
}
tab = newtab;
tab[num++] = utf_entry;
tab[num++] = entry;
}
vlc_closedir_wrapper( dir );
......
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