diff --git a/content/html/document/src/nsHTMLContentSink.cpp b/content/html/document/src/nsHTMLContentSink.cpp
index 475f82e0c86d..18f5a499b1bf 100644
--- a/content/html/document/src/nsHTMLContentSink.cpp
+++ b/content/html/document/src/nsHTMLContentSink.cpp
@@ -3168,7 +3168,7 @@ HTMLContentSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode)
*/
PRInt32 nameEnd = 0;
- if (name.Length() && name.First() != '"' && name.First() != '\'') {
+ if (name.IsEmpty() || (name.First() != '"' && name.First() != '\'')) {
nameEnd = name.FindCharInSet(" \n\r\t");
}
diff --git a/layout/html/document/src/nsHTMLContentSink.cpp b/layout/html/document/src/nsHTMLContentSink.cpp
index 475f82e0c86d..18f5a499b1bf 100644
--- a/layout/html/document/src/nsHTMLContentSink.cpp
+++ b/layout/html/document/src/nsHTMLContentSink.cpp
@@ -3168,7 +3168,7 @@ HTMLContentSink::AddDocTypeDecl(const nsIParserNode& aNode, PRInt32 aMode)
*/
PRInt32 nameEnd = 0;
- if (name.Length() && name.First() != '"' && name.First() != '\'') {
+ if (name.IsEmpty() || (name.First() != '"' && name.First() != '\'')) {
nameEnd = name.FindCharInSet(" \n\r\t");
}