From 4bf419574b51ced5dea893f9e247fe38a2a0d163 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sat, 17 Apr 2010 17:49:47 +0300 Subject: [PATCH] skins: use readdir_r() instead of readdir() --- modules/gui/skins2/x11/x11_factory.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/gui/skins2/x11/x11_factory.cpp b/modules/gui/skins2/x11/x11_factory.cpp index f203de836b..fa54582c1a 100644 --- a/modules/gui/skins2/x11/x11_factory.cpp +++ b/modules/gui/skins2/x11/x11_factory.cpp @@ -201,6 +201,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; @@ -208,7 +213,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; @@ -221,7 +226,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 ); } -- 2.39.2