Skip to content

Commit

Permalink
Reset HTML parser input pointers on encoding failure
Browse files Browse the repository at this point in the history
Call xmlBufResetInput before bailing out if switching the encoding
fails. Otherwise, the input pointers could be left in an invalid state.

Similar to commit f9e7997 for the
XML parser.

Thanks to Yunho Kim for the report.

Closes: #27
  • Loading branch information
nwellnhof committed Sep 11, 2018
1 parent dc6d2a4 commit 60173c8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion HTMLparser.c
Expand Up @@ -3636,12 +3636,12 @@ htmlCheckEncodingDirect(htmlParserCtxtPtr ctxt, const xmlChar *encoding) {
processed = ctxt->input->cur - ctxt->input->base;
xmlBufShrink(ctxt->input->buf->buffer, processed);
nbchars = xmlCharEncInput(ctxt->input->buf, 1);
xmlBufResetInput(ctxt->input->buf->buffer, ctxt->input);
if (nbchars < 0) {
htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING,
"htmlCheckEncoding: encoder error\n",
NULL, NULL);
}
xmlBufResetInput(ctxt->input->buf->buffer, ctxt->input);
}
}
}
Expand Down

0 comments on commit 60173c8

Please sign in to comment.