Bug 101294 - make sure that nsPref is never unhappy at construction time, r=caillon, sr=dveditz
--- 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.