summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2023-04-30 21:30:21 +0200
committerNick Wellnhofer <wellnhofer@aevum.de>2023-04-30 21:45:39 +0200
commit57d88da6757457b9dfa168c1f61a5b0850883850 (patch)
tree6822c6560f5d81183aea11171f3bd7e56c167906
parent0ffc2d82b5f733d5931515c3480c54b7621a1b8d (diff)
downloadlibxml2-57d88da6757457b9dfa168c1f61a5b0850883850.tar.gz
schemas: Fix memory leak in xmlSchemaValidateStream
Regressed in 9a82b94a. Fixes #530.
-rw-r--r--xmlschemas.c15
1 files 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);