Followup to bug 392251 - try to fix Ts regression by checking for directory existence before trying to enumerate it, r=dcamp on IRC
authorbenjamin@smedbergs.us
Mon, 27 Aug 2007 10:01:10 -0700
changeset 5335 1ca2da59d08ec795d16dd737111bd14e17b91928
parent 5334 04f396d00d4f99435870a4fb84044000dd4126a9
child 5336 63316f31a1bddcc0d76839e448029ff2081e6928
push idunknown
push userunknown
push dateunknown
reviewersdcamp
bugs392251
milestone1.9a8pre
Followup to bug 392251 - try to fix Ts regression by checking for directory existence before trying to enumerate it, r=dcamp on IRC
toolkit/xre/nsXREDirProvider.cpp
--- a/toolkit/xre/nsXREDirProvider.cpp
+++ b/toolkit/xre/nsXREDirProvider.cpp
@@ -546,16 +546,20 @@ LoadAppBundlesIntoArray(nsIFile* aXULApp
   nsCOMPtr<nsIFile> dir;
   nsresult rv = aXULAppDir->Clone(getter_AddRefs(dir));
   if (NS_FAILED(rv))
     return;
 
   dir->AppendNative(NS_LITERAL_CSTRING("distribution"));
   dir->AppendNative(NS_LITERAL_CSTRING("bundles"));
 
+  PRBool exists;
+  if (NS_FAILED(dir->Exists(&exists)) || !exists)
+    return;
+
   nsCOMPtr<nsISimpleEnumerator> e;
   rv = dir->GetDirectoryEntries(getter_AddRefs(e));
   if (NS_FAILED(rv))
     return;
 
   nsCOMPtr<nsIDirectoryEnumerator> files = do_QueryInterface(e);
   if (!files)
     return;
@@ -568,17 +572,16 @@ LoadAppBundlesIntoArray(nsIFile* aXULApp
       break;
 
     const char* const* a = aAppendList;
     while (*a) {
       subdir->AppendNative(nsDependentCString(*a));
       ++a;
     }
     
-    PRBool exists;
     rv = subdir->Exists(&exists);
     if (NS_SUCCEEDED(rv) && exists)
       aDirectories.AppendObject(subdir);
 
     LoadAppPlatformDirIntoArray(file, aAppendList, aDirectories);
   }
 }