diff --git a/html/src/TDocOutput.cxx b/html/src/TDocOutput.cxx
index a6a2b68d5e5d7c888205423f26af8cb8fda246b1..3fa29e0f62d7b7e5e319bcbf29dcdabfaf9fb876 100644
--- a/html/src/TDocOutput.cxx
+++ b/html/src/TDocOutput.cxx
@@ -325,7 +325,7 @@ void TDocOutput::Convert(std::istream& in, const char* infilename,
    // write a HTML header
    WriteHtmlHeader(out, title, relpath);
 
-   if (context || context[0])
+   if (context && context[0])
       out << context << endl;
    else if (title && title[0])
       out << "<h1 class=\"convert\">" << title << "</h1>" << endl;
@@ -1772,10 +1772,13 @@ void TDocOutput::ReferenceEntity(TSubString& str, TDataMember* entity, const cha
    fHtml->GetHtmlFileName(scope, link);
    link += "#";
 
-   TString mangledName(scope->GetName());
-   NameSpace2FileName(mangledName);
-   link += mangledName;
-   link += ":";
+   TString mangledName;
+   if (scope) {
+      mangledName = scope->GetName();
+      NameSpace2FileName(mangledName);
+      link += mangledName;
+      link += ":";
+   }
 
    mangledName = entity->GetName();
    NameSpace2FileName(mangledName);
@@ -2425,8 +2428,11 @@ void TDocOutput::WriteTopLinks(std::ostream& out, TModuleDocInfo* module, const
    // link to the user home page (if exist)
    const char* userHomePage = GetHtml()->GetHomepage();
    const char* productName = fHtml->GetProductName();
-   if (productName && !strcmp(productName, "ROOT"))
+   if (!productName) {
+      productName = "";
+   } else if (!strcmp(productName, "ROOT")) {
       userHomePage = "";
+   }
    if (userHomePage && *userHomePage)
       out << "<a class=\"descrheadentry\" href=\"" << userHomePage << "\">" << productName << "</a>" << endl;
    out << "<a class=\"descrheadentry\" href=\"http://root.cern.ch\">ROOT Homepage</a>" << endl
diff --git a/html/src/THtml.cxx b/html/src/THtml.cxx
index 3f7a4e2e45c58206a00fd0f1304f04718b89d507..5e27e6fa55f2cfbc626b7cb14bb51541fbd25011 100644
--- a/html/src/THtml.cxx
+++ b/html/src/THtml.cxx
@@ -1542,6 +1542,8 @@ void  THtml::GetModuleNameForClass(TString& module, TClass* cl) const
    // Use the cached information from fDocEntityInfo.fClasses.
 
    module = "(UNKNOWN)";
+   if (!cl) return;
+
    TClassDocInfo* cdi = (TClassDocInfo*)fDocEntityInfo.fClasses.FindObject(cl->GetName());
    if (!cdi || !cdi->GetModule())
       return;