1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-08-13 21:49:22 +03:00

html: Fix UAF in htmlCurrentChar

Short-lived regression found by OSS-Fuzz.
This commit is contained in:
Nick Wellnhofer
2023-08-09 18:39:14 +02:00
parent b973ceaf2f
commit 5db5a704eb

View File

@ -445,7 +445,6 @@ htmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
xmlSwitchEncoding(ctxt, XML_CHAR_ENCODING_8859_1);
} else {
handler = xmlFindCharEncodingHandler((const char *) guess);
xmlFree(guess);
if (handler != NULL) {
/*
* Don't use UTF-8 encoder which isn't required and
@ -457,6 +456,7 @@ htmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING,
"Unsupported encoding %s", guess, NULL);
}
xmlFree(guess);
}
ctxt->input->flags |= XML_INPUT_HAS_ENCODING;
}