Commit 8d86389f authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

vlc_readdir: thread-safety fix

Use readdir_r() instead of readdir().
(cherry picked from commit ed9336c9de1770273a0b0a05d0c727b3387ac11e)
parent 367a128e
...@@ -322,12 +322,18 @@ char *vlc_readdir( DIR *dir ) ...@@ -322,12 +322,18 @@ char *vlc_readdir( DIR *dir )
return FromWide (ent->d_name); return FromWide (ent->d_name);
#else #else
struct dirent *ent; struct dirent *ent;
struct
ent = readdir( (DIR *)dir ); {
if( ent == NULL ) struct dirent ent;
char buf[NAME_MAX + 1];
} buf;
int val = readdir_r (dir, &buf.ent, &ent);
if (val)
{
errno = val;
return NULL; return NULL;
}
return vlc_fix_readdir( ent->d_name ); return ent ? vlc_fix_readdir( ent->d_name ) : NULL;
#endif #endif
} }
......
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