diff --git a/htmlparser/src/CNavDTD.cpp b/htmlparser/src/CNavDTD.cpp
index 183b7e0bf05..aed5c2d17c6 100644
--- a/htmlparser/src/CNavDTD.cpp
+++ b/htmlparser/src/CNavDTD.cpp
@@ -891,7 +891,7 @@ nsresult CNavDTD::DidHandleStartTag(nsCParserNode& aNode,eHTMLTags aChildTag){
//handle tags by generating a close tag...
//added this to fix bug 48351, which contains XHTML and uses empty tags.
- if(nsHTMLElement::IsContainer(aChildTag)) {
+ if(nsHTMLElement::IsContainer(aChildTag) && aNode.mToken) { //nullptr test fixes bug 56085
CStartToken *theToken=NS_STATIC_CAST(CStartToken*,aNode.mToken);
if(theToken->IsEmpty()){
diff --git a/parser/htmlparser/src/CNavDTD.cpp b/parser/htmlparser/src/CNavDTD.cpp
index 183b7e0bf05..aed5c2d17c6 100644
--- a/parser/htmlparser/src/CNavDTD.cpp
+++ b/parser/htmlparser/src/CNavDTD.cpp
@@ -891,7 +891,7 @@ nsresult CNavDTD::DidHandleStartTag(nsCParserNode& aNode,eHTMLTags aChildTag){
//handle tags by generating a close tag...
//added this to fix bug 48351, which contains XHTML and uses empty tags.
- if(nsHTMLElement::IsContainer(aChildTag)) {
+ if(nsHTMLElement::IsContainer(aChildTag) && aNode.mToken) { //nullptr test fixes bug 56085
CStartToken *theToken=NS_STATIC_CAST(CStartToken*,aNode.mToken);
if(theToken->IsEmpty()){