diff --git a/parser/htmlparser/src/CNavDTD.cpp b/parser/htmlparser/src/CNavDTD.cpp
index 7742d71374ae..78bbd4f2b5f3 100644
--- a/parser/htmlparser/src/CNavDTD.cpp
+++ b/parser/htmlparser/src/CNavDTD.cpp
@@ -371,6 +371,7 @@ CNavDTD::BuildNeglectedTarget(eHTMLTags aTarget,
}
CToken* target = mTokenAllocator->CreateTokenOfType(aType, aTarget);
+ NS_ENSURE_TRUE(target, NS_ERROR_OUT_OF_MEMORY);
mTokenizer->PushTokenFront(target);
return BuildModel(aParser, mTokenizer, 0, aSink);
}
@@ -1156,10 +1157,7 @@ CNavDTD::HandleKeyGen(nsIParserNode* aNode)
//