diff --git a/modules/libpref/src/nsPref.cpp b/modules/libpref/src/nsPref.cpp index 938c0288babd..45542314a0af 100644 --- a/modules/libpref/src/nsPref.cpp +++ b/modules/libpref/src/nsPref.cpp @@ -709,10 +709,13 @@ NS_IMETHODIMP nsPref::SecurityClearUserPref(const char *pref_name) 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