Bug 101294 - make sure that nsPref is never unhappy at construction time, r=caillon, sr=dveditz
authortimeless@mozdev.org
Thu, 15 Jan 2009 20:02:22 -0800
changeset 23784 908c5a39cdd369e26dc14ab2d85ee50420c0f1d9
parent 23783 549c937170ec49b8726454ced5a1893ab09783a7
child 23785 994388063d689928d9f9340c0d03a9fae7a0b325
push id4722
push userphilringnalda@gmail.com
push dateFri, 16 Jan 2009 04:03:22 +0000
treeherdermozilla-central@57e38d817e3f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscaillon, dveditz
bugs101294
milestone1.9.2a1pre
Bug 101294 - make sure that nsPref is never unhappy at construction time, r=caillon, sr=dveditz
modules/libpref/src/nsPref.cpp
--- a/modules/libpref/src/nsPref.cpp
+++ b/modules/libpref/src/nsPref.cpp
@@ -704,20 +704,23 @@ NS_IMETHODIMP nsPref::SecurityClearUserP
   return rv;
 }
 
 
 //----------------------------------------------------------------------------------------
 nsPref* nsPref::GetInstance()
 //----------------------------------------------------------------------------------------
 {
+  if (gInstance)
+    return gInstance;
+  NS_NEWXPCOM(gInstance, nsPref);
   if (!gInstance)
-  {
-    NS_NEWXPCOM(gInstance, nsPref);
-  }
+    return nsnull;
+  if (!gInstance->mPrefService)
+    NS_RELEASE(gInstance);
   return gInstance;
 } // nsPref::GetInstance
 
 
 //----------------------------------------------------------------------------------------
 // Functions used to create new instances of a given object by the
 // generic factory.