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