diff --git a/HTMLparser.c b/HTMLparser.c
index dd0c1ead..7694962a 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -5991,7 +5991,7 @@ done:
ctxt->sax->endDocument(ctxt->userData);
}
}
- if ((ctxt->myDoc != NULL) &&
+ if ((!(ctxt->options & HTML_PARSE_NODEFDTD)) && (ctxt->myDoc != NULL) &&
((terminate) || (ctxt->instate == XML_PARSER_EOF) ||
(ctxt->instate == XML_PARSER_EPILOG))) {
xmlDtdPtr dtd;
diff --git a/xmllint.c b/xmllint.c
index d69722c4..ebd36ab0 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -2206,6 +2206,7 @@ static void parseAndPrintFile(char *filename, xmlParserCtxtPtr rectxt) {
if (res > 0) {
ctxt = htmlCreatePushParserCtxt(NULL, NULL,
chars, res, filename, XML_CHAR_ENCODING_NONE);
+ xmlCtxtUseOptions(ctxt, options);
while ((res = fread(chars, 1, pushsize, f)) > 0) {
htmlParseChunk(ctxt, chars, res, 0);
}