1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-24 21:33:51 +03:00

xmllint: Fix resetting error in xmlHTMLPrintError

Make sure that we don't change the error handler when fuzzing.
This commit is contained in:
Nick Wellnhofer 2024-06-16 17:36:05 +02:00
parent 481fd6bbee
commit c9b065914f

View File

@ -485,12 +485,16 @@ static void
xmlHTMLPrintError(void *ctx, const char *level, const char *msg, va_list ap) { xmlHTMLPrintError(void *ctx, const char *level, const char *msg, va_list ap) {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlParserInputPtr input; xmlParserInputPtr input;
xmlGenericErrorFunc oldError;
void *oldErrorCtxt;
input = ctxt->input; input = ctxt->input;
if ((input != NULL) && (input->filename == NULL) && (ctxt->inputNr > 1)) { if ((input != NULL) && (input->filename == NULL) && (ctxt->inputNr > 1)) {
input = ctxt->inputTab[ctxt->inputNr - 2]; input = ctxt->inputTab[ctxt->inputNr - 2];
} }
oldError = xmlGenericError;
oldErrorCtxt = xmlGenericErrorContext;
xmlSetGenericErrorFunc(NULL, xmlHTMLBufCat); xmlSetGenericErrorFunc(NULL, xmlHTMLBufCat);
fprintf(ERR_STREAM, "<p>"); fprintf(ERR_STREAM, "<p>");
@ -514,7 +518,7 @@ xmlHTMLPrintError(void *ctx, const char *level, const char *msg, va_list ap) {
fprintf(ERR_STREAM, "</pre>"); fprintf(ERR_STREAM, "</pre>");
} }
xmlSetGenericErrorFunc(NULL, NULL); xmlSetGenericErrorFunc(oldErrorCtxt, oldError);
} }
/** /**