[vlc-commits] commit: skins: use readdir_r() instead of readdir() ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Sat Apr 17 16:57:59 CEST 2010


vlc/vlc-1.0 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Apr 17 17:49:47 2010 +0300| [d7347197e0c12c2f3d096e691e2800d87a942ed8] | committer: Rémi Denis-Courmont 

skins: use readdir_r() instead of readdir()
(cherry picked from commit 4bf419574b51ced5dea893f9e247fe38a2a0d163)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.0.git/?a=commit;h=d7347197e0c12c2f3d096e691e2800d87a942ed8
---

 modules/gui/skins2/x11/x11_factory.cpp |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/modules/gui/skins2/x11/x11_factory.cpp b/modules/gui/skins2/x11/x11_factory.cpp
index fe80a7b..774c3a8 100644
--- a/modules/gui/skins2/x11/x11_factory.cpp
+++ b/modules/gui/skins2/x11/x11_factory.cpp
@@ -197,6 +197,11 @@ void X11Factory::getMousePos( int &rXPos, int &rYPos ) const
 
 void X11Factory::rmDir( const string &rPath )
 {
+    struct
+    {
+        struct dirent ent;
+        char buf[NAME_MAX + 1];
+    } buf;
     struct dirent *file;
     DIR *dir;
 
@@ -204,7 +209,7 @@ void X11Factory::rmDir( const string &rPath )
     if( !dir ) return;
 
     // Parse the directory and remove everything it contains
-    while( (file = readdir( dir )) )
+    while( readdir_r( dir, &buf.ent, &file ) == 0 && file != NULL )
     {
         struct stat statbuf;
         string filename = file->d_name;
@@ -217,7 +222,7 @@ void X11Factory::rmDir( const string &rPath )
 
         filename = rPath + "/" + filename;
 
-        if( !stat( filename.c_str(), &statbuf ) && statbuf.st_mode & S_IFDIR )
+        if( !stat( filename.c_str(), &statbuf ) && S_ISDIR(statbuf.st_mode) )
         {
             rmDir( filename );
         }



More information about the vlc-commits mailing list