Page 1 of 1

vlc 2.2.0-rc2 please check that vlc_DIR.

Posted: 15 Feb 2015 10:31
by JoungEunKim
/include/vlc_fs.h

***line 48

#if defined( _WIN32 )
typedef struct vlc_DIR
{
_WDIR *wdir; /* MUST be first, see <vlc_fs.h> */
char *entry; <------------ this is new in 2.2.0
union
{
DWORD drives;
bool insert_dot_dot;
} u;
} vlc_DIR;



/src/win32/filesystem.c

***line 171

char *vlc_readdir (DIR *dir)
{
vlc_DIR *p_dir = (vlc_DIR *)dir;

free(p_dir->entry); <---------- this is a little problem. and other part to use entry. Because p_dir is type cast from (DIR *), struct DIR size is less then struct vlc_DIR.
I think after call vlc_readdir(), it need to free return value. But this is not right way. :wink:
Please check about that. :)


#if !VLC_WINSTORE_APP
/* Drive letters mode */
if (p_dir->wdir == NULL)
{
DWORD drives = p_dir->u.drives;
if (drives == 0)
return NULL; /* end */

unsigned int i;
for (i = 0; !(drives & 1); i++)
drives >>= 1;
p_dir->u.drives &= ~(1UL << i);
assert (i < 26);

if (asprintf (&p_dir->entry, "%c:\\", 'A' + i) == -1)
p_dir->entry = NULL;
}
else
#endif
if (p_dir->u.insert_dot_dot)
{
/* Adds "..", gruik! */
p_dir->u.insert_dot_dot = false;
p_dir->entry = strdup ("..");
}
else
{
struct _wdirent *ent = _wreaddir (p_dir->wdir);
p_dir->entry = (ent != NULL) ? FromWide (ent->d_name) : NULL;
}
return p_dir->entry;
}

Re: vlc 2.2.0-rc2 please check that vlc_DIR.

Posted: 17 Feb 2015 04:10
by JoungEunKim
Hi.

I'm sorry I misunderstand typecast part.

/src/win32/filesystem.c

***line 171

char *vlc_readdir (DIR *dir)
{
vlc_DIR *p_dir = (vlc_DIR *)dir; <----------- This parameter dir is to make with vlc_opendir(). dir value is same vlc_DIR *.


I'm very sorry. :oops:

If you have a time, please to check before free(p_dir->entry) and to set NULL.

like...

vlc_fs.h

static inline int vlc_closedir( DIR *dir )
{
vlc_DIR *vdir = (vlc_DIR *)dir;
_WDIR *wdir = vdir->wdir;

if (vdir->entry != NULL)
free( vdir->entry );


filesystem.c

char *vlc_readdir (DIR *dir)
{
vlc_DIR *p_dir = (vlc_DIR *)dir;

if (p_dir->entry != NULL)
{
free(p_dir->entry);
p_dir->entry = NULL;
}




Have a nice day~~~