Index: trunk/Mars/mbase/MDirIter.cc
===================================================================
--- trunk/Mars/mbase/MDirIter.cc	(revision 14966)
+++ trunk/Mars/mbase/MDirIter.cc	(revision 14993)
@@ -348,5 +348,4 @@
     // Check for rread perissions
     return !gSystem->AccessPathName(fqp, kReadPermission);
-
 }
 
@@ -374,16 +373,24 @@
 TString MDirIter::Next(Bool_t nocheck)
 {
-    fDirPtr = Open();
-    if (!fDirPtr)
-        return "";
-
-    // Get next entry in dir, if existing check validity
-    const char *n = gSystem->GetDirEntry(fDirPtr);
-    if (n)
-        return nocheck || CheckEntry(n) ? ConcatFileName(fCurrentPath->GetName(), n) : Next();
-
-    // Otherwise close directory and try to get next entry
-    Close();
-    return Next();
+    while (1)
+    {
+        fDirPtr = Open();
+        if (!fDirPtr)
+            break;
+
+        // Get next entry in dir, if existing check validity
+        const char *n = gSystem->GetDirEntry(fDirPtr);
+        if (!n)
+        {
+            // Otherwise close directory and try to get next entry
+            Close();
+            continue;
+        }
+
+        if (nocheck || CheckEntry(n))
+            return ConcatFileName(fCurrentPath->GetName(), n);
+    }
+
+    return "";
 }
 
