add opendir() error check to fix readdir() crash

This commit is contained in:
Glenn Maynard
2004-05-27 04:48:31 +00:00
parent 6ec5593cbe
commit b1b33f7db0
@@ -282,7 +282,16 @@ void DirectFilenameDB::PopulateFileSet( FileSet &fs, const CString &path )
close( OldDir );
return;
}
DIR *d = opendir(".");
if( d == NULL )
{
LOG->MapLog("opendir " + root+"/"+sPath, "Couldn't opendir(%s%s): %s", root.c_str(), sPath.c_str(), strerror(errno) );
if( fchdir( OldDir ) == -1 )
RageException::Throw( "Couldn't fchdir(): %s", strerror(errno) );
close( OldDir );
return;
}
while(struct dirent *ent = readdir(d))
{