vlc 2.2.0-rc2 please check that vlc_DIR.

Microsoft Windows specific usage questions
Forum rules
Please post only Windows specific questions in this forum category. If you don't know where to post, please read the different forums' rules. Thanks.
JoungEunKim
Cone that earned his stripes
Cone that earned his stripes
Posts: 150
Joined: 10 Dec 2009 00:21

vlc 2.2.0-rc2 please check that vlc_DIR.

Postby JoungEunKim » 15 Feb 2015 10:31

/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;
}

JoungEunKim
Cone that earned his stripes
Cone that earned his stripes
Posts: 150
Joined: 10 Dec 2009 00:21

Re: vlc 2.2.0-rc2 please check that vlc_DIR.

Postby JoungEunKim » 17 Feb 2015 04:10

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~~~


Return to “VLC media player for Windows Troubleshooting”

Who is online

Users browsing this forum: No registered users and 31 guests