diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp
index 9bec9f02f6c..043be65f67d 100644
--- a/mozilla/content/html/document/src/nsHTMLDocument.cpp
+++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp
@@ -429,7 +429,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
if(! gInitDetector)
{
nsIPref* pref = nsnull;
- if(NS_SUCCEEDED(webShell->GetPrefs(pref)))
+ if(NS_SUCCEEDED(webShell->GetPrefs(pref)) && pref)
{
char* detector_name = nsnull;
diff --git a/mozilla/layout/html/document/src/nsHTMLDocument.cpp b/mozilla/layout/html/document/src/nsHTMLDocument.cpp
index 9bec9f02f6c..043be65f67d 100644
--- a/mozilla/layout/html/document/src/nsHTMLDocument.cpp
+++ b/mozilla/layout/html/document/src/nsHTMLDocument.cpp
@@ -429,7 +429,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
if(! gInitDetector)
{
nsIPref* pref = nsnull;
- if(NS_SUCCEEDED(webShell->GetPrefs(pref)))
+ if(NS_SUCCEEDED(webShell->GetPrefs(pref)) && pref)
{
char* detector_name = nsnull;