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];
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 ) )
{
for( ;; )
{
- const char *psz_filename;
+ char *psz_filename;
/* parse psz_src dir */
if( ( psz_filename = utf8_readdir( p_dir ) ) == NULL )
{
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 ) )
{
#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) ||
/*****************************************************************************
* 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>
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;
strcmp( psz_entry, ".." ) )
{
free( psz_entry );
- psz_entry = utf8_readdir( p_current_dir );
continue;
}
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
free( psz_uri );
free( psz_entry );
- /* Read next entry */
- psz_entry = utf8_readdir( p_current_dir );
}
/* Sort */
*
* @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 )
{