From 57d88da6757457b9dfa168c1f61a5b0850883850 Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Sun, 30 Apr 2023 21:30:21 +0200 Subject: schemas: Fix memory leak in xmlSchemaValidateStream Regressed in 9a82b94a. Fixes #530. --- xmlschemas.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/xmlschemas.c b/xmlschemas.c index a4eaf591..4662ebbf 100644 --- a/xmlschemas.c +++ b/xmlschemas.c @@ -29098,9 +29098,18 @@ xmlSchemaValidateStream(xmlSchemaValidCtxtPtr ctxt, /* * prepare the parser */ - pctxt = xmlNewSAXParserCtxt(sax, user_data); - if (pctxt == NULL) - return (-1); + if (sax != NULL) { + pctxt = xmlNewSAXParserCtxt(sax, user_data); + if (pctxt == NULL) + return (-1); + } else { + pctxt = xmlNewParserCtxt(); + if (pctxt == NULL) + return (-1); + /* We really want pctxt->sax to be NULL here. */ + xmlFree(pctxt->sax); + pctxt->sax = NULL; + } #if 0 if (options) xmlCtxtUseOptions(pctxt, options); -- cgit v1.2.1