Adding some missing NULL checks

in SAX2 DOM building code and in the HTML parser
diff --git a/HTMLparser.c b/HTMLparser.c
index dff8e1d..c26389f 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -3671,13 +3671,13 @@
     int i;
     int discardtag = 0;
 
-    if (ctxt->instate == XML_PARSER_EOF)
-        return(-1);
     if ((ctxt == NULL) || (ctxt->input == NULL)) {
 	htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
 		     "htmlParseStartTag: context error\n", NULL, NULL);
 	return -1;
     }
+    if (ctxt->instate == XML_PARSER_EOF)
+        return(-1);
     if (CUR != '<') return -1;
     NEXT;