[vlc-commits] commit: vlc_readdir: thread-safety fix ( Rémi Denis-Courmont )
git at videolan.org
git at videolan.org
Sat Apr 17 16:57:58 CEST 2010
vlc/vlc-1.0 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Apr 17 17:43:59 2010 +0300| [6108f3bb42dddb38931f31e0e3abbee38be15b67] | committer: Rémi Denis-Courmont
vlc_readdir: thread-safety fix
Use readdir_r() instead of readdir().
(cherry picked from commit ed9336c9de1770273a0b0a05d0c727b3387ac11e)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.0.git/?a=commit;h=6108f3bb42dddb38931f31e0e3abbee38be15b67
---
src/text/filesystem.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/text/filesystem.c b/src/text/filesystem.c
index bc602ae..9afb905 100644
--- a/src/text/filesystem.c
+++ b/src/text/filesystem.c
@@ -271,12 +271,18 @@ char *utf8_readdir( DIR *dir )
return FromWide (ent->d_name);
#else
struct dirent *ent;
-
- ent = readdir( (DIR *)dir );
- if( ent == NULL )
+ struct
+ {
+ struct dirent ent;
+ char buf[NAME_MAX + 1];
+ } buf;
+ int val = readdir_r (dir, &buf.ent, &ent);
+ if (val)
+ {
+ errno = val;
return NULL;
-
- return vlc_fix_readdir( ent->d_name );
+ }
+ return ent ? vlc_fix_readdir( ent->d_name ) : NULL;
#endif
}
More information about the vlc-commits
mailing list