diff --git a/HTMLparser.c b/HTMLparser.c
index 3d4831ce..da3b173d 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -3478,6 +3478,8 @@ htmlCheckEncoding(htmlParserCtxtPtr ctxt, const xmlChar *attvalue) {
}
ctxt->input->base =
ctxt->input->cur = ctxt->input->buf->buffer->content;
+ ctxt->input->end =
+ &ctxt->input->base[ctxt->input->buf->buffer->use];
}
}
}