Bug 395618. UseUserPrefFile should check that user.js exists. r/sr/a=bsmedberg
authorsayrer@gmail.com
Sat, 15 Sep 2007 12:32:51 -0700
changeset 5906 e80a6231ea8a849760275010fece548855cc3352
parent 5905 7086cced1ecc6eb64ea596e8b8020f9baf09da9b
child 5907 709bc82902e928c2fe336f9d4491fbeb9108eb2f
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs395618
milestone1.9a8pre
Bug 395618. UseUserPrefFile should check that user.js exists. r/sr/a=bsmedberg
modules/libpref/src/nsPrefService.cpp
--- a/modules/libpref/src/nsPrefService.cpp
+++ b/modules/libpref/src/nsPrefService.cpp
@@ -347,17 +347,23 @@ nsresult nsPrefService::UseUserPrefFile(
 #else
   nsDependentCString prefsDirProp(NS_APP_PREFS_50_DIR);
 #endif
 
   rv = NS_GetSpecialDirectory(prefsDirProp.get(), getter_AddRefs(aFile));
   if (NS_SUCCEEDED(rv) && aFile) {
     rv = aFile->AppendNative(NS_LITERAL_CSTRING("user.js"));
     if (NS_SUCCEEDED(rv)) {
-      rv = openPrefFile(aFile);
+      PRBool exists = PR_FALSE;
+      aFile->Exists(&exists);
+      if (exists) {
+        rv = openPrefFile(aFile);
+      } else {
+        rv = NS_ERROR_FILE_NOT_FOUND;
+      }
     }
   }
   return rv;
 }
 
 nsresult nsPrefService::MakeBackupPrefFile(nsIFile *aFile)
 {
   // Example: this copies "prefs.js" to "Invalidprefs.js" in the same directory.