diff --git a/indra/llvfs/lldiriterator.cpp b/indra/llvfs/lldiriterator.cpp
index 460d2a8b4fb70757cea4ce18e2b23ecb35b855d0..229608231ca5ccfc88a17d2ba85b7f3f7d062ce8 100755
--- a/indra/llvfs/lldiriterator.cpp
+++ b/indra/llvfs/lldiriterator.cpp
@@ -119,16 +119,25 @@ bool LLDirIterator::Impl::next(std::string &fname)
 
 	fs::directory_iterator end_itr; // default construction yields past-the-end
 	bool found = false;
-	while (mIter != end_itr && !found)
+
+	// Check if path is a directory.
+	try
 	{
-		boost::smatch match;
-		std::string name = mIter->path().filename().string();
-		if (found = boost::regex_match(name, match, mFilterExp))
+		while (mIter != end_itr && !found)
 		{
-			fname = name;
+			boost::smatch match;
+			std::string name = mIter->path().filename().string();
+			if (found = boost::regex_match(name, match, mFilterExp))
+			{
+				fname = name;
+			}
+
+			++mIter;
 		}
-
-		++mIter;
+	}
+	catch (const fs::filesystem_error& e)
+	{
+		llwarns << e.what() << llendl;
 	}
 
 	return found;