Commit 45915c74 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

Fix utf8_readdir usage

parent 9b84d144
......@@ -149,7 +149,7 @@ int E_(ParseDirectory)( intf_thread_t *p_intf, char *psz_root,
msg_Dbg( p_intf, "dir=%s", psz_dir );
sprintf( dir, "%s%c.access", psz_dir, sep );
snprintf( dir, sizeof( dir ), "%s%c.access", psz_dir, sep );
if( ( file = utf8_fopen( dir, "r" ) ) != NULL )
{
char line[1024];
......@@ -183,7 +183,7 @@ int E_(ParseDirectory)( intf_thread_t *p_intf, char *psz_root,
fclose( file );
}
sprintf( dir, "%s%c.hosts", psz_dir, sep );
snprintf( dir, sizeof( dir ), "%s%c.hosts", psz_dir, sep );
p_acl = ACL_Create( p_intf, VLC_FALSE );
if( ACL_LoadFile( p_acl, dir ) )
{
......@@ -193,7 +193,7 @@ int E_(ParseDirectory)( intf_thread_t *p_intf, char *psz_root,
for( ;; )
{
const char *psz_filename;
char *psz_filename;
/* parse psz_src dir */
if( ( psz_filename = utf8_readdir( p_dir ) ) == NULL )
{
......@@ -202,10 +202,13 @@ int E_(ParseDirectory)( intf_thread_t *p_intf, char *psz_root,
if( ( psz_filename[0] == '.' )
|| ( i_dirlen + strlen( psz_filename ) > MAX_DIR_SIZE ) )
{
free( psz_filename );
continue;
}
sprintf( dir, "%s%c%s", psz_dir, sep, psz_filename );
free( (char*) psz_filename );
snprintf( dir, sizeof( dir ), "%s%c%s", psz_dir, sep, psz_filename );
free( psz_filename );
if( E_(ParseDirectory)( p_intf, psz_root, dir ) )
{
......
......@@ -1532,7 +1532,10 @@ static int Open( vlc_object_t * p_this )
#else
if (!s_filename.compare(p_demux->psz_path))
#endif
{
free (psz_file);
continue; // don't reuse the original opened file
}
#if defined(__GNUC__) && (__GNUC__ < 3)
if (!s_filename.compare("mkv", s_filename.length() - 3, 3) ||
......
......@@ -27,12 +27,13 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <vlc/vlc.h>
#include <errno.h> /* ENOMEM */
#include <time.h>
#include <curses.h>
#include <vlc/vlc.h>
#include <vlc_interface.h>
#include <vlc_vout.h>
#include <vlc_aout.h>
......@@ -1927,11 +1928,8 @@ static void ReadDir( intf_thread_t *p_intf )
p_sys->pp_dir_entries = NULL;
p_sys->i_dir_entries = 0;
/* get the first directory entry */
psz_entry = utf8_readdir( p_current_dir );
/* while we still have entries in the directory */
while( psz_entry != NULL )
while( ( psz_entry = utf8_readdir( p_current_dir ) ) != NULL )
{
#if defined( S_ISDIR )
struct stat stat_data;
......@@ -1946,7 +1944,6 @@ static void ReadDir( intf_thread_t *p_intf )
strcmp( psz_entry, ".." ) )
{
free( psz_entry );
psz_entry = utf8_readdir( p_current_dir );
continue;
}
......@@ -1955,13 +1952,14 @@ static void ReadDir( intf_thread_t *p_intf )
if( !( p_dir_entry = malloc( sizeof( struct dir_entry_t) ) ) )
{
free( psz_uri);
return;
free( psz_uri );
free( psz_entry );
continue;
}
#if defined( S_ISDIR )
utf8_stat( psz_uri, &stat_data );
if( S_ISDIR(stat_data.st_mode) )
if( !utf8_stat( psz_uri, &stat_data )
&& S_ISDIR(stat_data.st_mode) )
/*#elif defined( DT_DIR )
if( p_dir_content->d_type & DT_DIR )*/
#else
......@@ -1983,8 +1981,6 @@ static void ReadDir( intf_thread_t *p_intf )
free( psz_uri );
free( psz_entry );
/* Read next entry */
psz_entry = utf8_readdir( p_current_dir );
}
/* Sort */
......
......@@ -416,7 +416,7 @@ DIR *utf8_opendir( const char *dirname )
*
* @param dir The directory that is being read
*
* @return a UTF-8 string of the directory entry. Use LocaleFree() to free this memory
* @return a UTF-8 string of the directory entry. Use free() to free this memory.
*/
char *utf8_readdir( DIR *dir )
{
......
Supports Markdown
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