diff --git a/HTMLparser.c b/HTMLparser.c
index 5b7016be..e192f500 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -2274,7 +2274,6 @@ htmlNewInputStream(htmlParserCtxtPtr ctxt) {
input->free = NULL;
input->version = NULL;
input->consumed = 0;
- input->length = 0;
return(input);
}
#endif
diff --git a/include/libxml/parser.h b/include/libxml/parser.h
index f5628268..31be8aed 100644
--- a/include/libxml/parser.h
+++ b/include/libxml/parser.h
@@ -64,7 +64,7 @@ struct _xmlParserInput {
const xmlChar *base; /* Base of the array to parse */
const xmlChar *cur; /* Current char being parsed */
const xmlChar *end; /* end of the array to parse */
- int length; /* length if known */
+ int length; /* unused */
int line; /* Current line */
int col; /* Current column */
unsigned long consumed; /* How many xmlChars already consumed */
diff --git a/parserInternals.c b/parserInternals.c
index 79708cf0..e798f38c 100644
--- a/parserInternals.c
+++ b/parserInternals.c
@@ -1548,6 +1548,12 @@ xmlNewEntityInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
}
return(NULL);
}
+
+ /*
+ * We create an input stream with a NULL buffer here and make the
+ * input pointers reference the entity content directly. This is
+ * unusual and somewhat dangerous.
+ */
input = xmlNewInputStream(ctxt);
if (input == NULL) {
return(NULL);
@@ -1558,9 +1564,9 @@ xmlNewEntityInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
if (entity->length == 0)
entity->length = xmlStrlen(entity->content);
input->cur = entity->content;
- input->length = entity->length;
- input->end = &entity->content[input->length];
+ input->end = &entity->content[entity->length];
input->entity = entity;
+
return(input);
}