1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-31 06:50:06 +03:00

malloc-fail: Fix infinite loop in xmlParseTextDecl

Memory errors can set `instate` to `XML_PARSER_EOF` which results in
`NEXT` making no progress.

Found with libFuzzer, see #344.
This commit is contained in:
Nick Wellnhofer 2023-01-22 17:42:09 +01:00
parent bd9de3a31f
commit d1b8785693

View File

@ -7046,6 +7046,8 @@ xmlParseTextDecl(xmlParserCtxtPtr ctxt) {
* We must have the encoding declaration
*/
encoding = xmlParseEncodingDecl(ctxt);
if (ctxt->instate == XML_PARSER_EOF)
return;
if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
/*
* The XML REC instructs us to stop parsing right here