mirror of
https://github.com/GNOME/libxml2.git
synced 2025-05-09 21:31:17 +08:00
xmllint: Fix memory leak in parseFile
Short-lived regression.
This commit is contained in:
parent
0f4d36e055
commit
d39e5714b0
17
xmllint.c
17
xmllint.c
@ -1927,6 +1927,10 @@ error:
|
|||||||
static xmlDocPtr
|
static xmlDocPtr
|
||||||
parseFile(const char *filename, xmlParserCtxtPtr ctxt) {
|
parseFile(const char *filename, xmlParserCtxtPtr ctxt) {
|
||||||
xmlDocPtr doc = NULL;
|
xmlDocPtr doc = NULL;
|
||||||
|
int errNo;
|
||||||
|
#ifdef LIBXML_VALID_ENABLED
|
||||||
|
int valid;
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((generate) && (filename == NULL)) {
|
if ((generate) && (filename == NULL)) {
|
||||||
xmlNodePtr n;
|
xmlNodePtr n;
|
||||||
@ -2041,25 +2045,34 @@ parseFile(const char *filename, xmlParserCtxtPtr ctxt) {
|
|||||||
xmlParseChunk(ctxt, chars, 0, 1);
|
xmlParseChunk(ctxt, chars, 0, 1);
|
||||||
|
|
||||||
doc = ctxt->myDoc;
|
doc = ctxt->myDoc;
|
||||||
|
errNo = ctxt->errNo;
|
||||||
|
#ifdef LIBXML_VALID_ENABLED
|
||||||
|
valid = ctxt->valid;
|
||||||
|
#endif
|
||||||
|
xmlFreeParserCtxt(ctxt);
|
||||||
if (f != stdin)
|
if (f != stdin)
|
||||||
fclose(f);
|
fclose(f);
|
||||||
} else
|
} else
|
||||||
#endif /* LIBXML_PUSH_ENABLED */
|
#endif /* LIBXML_PUSH_ENABLED */
|
||||||
{
|
{
|
||||||
doc = parseXml(ctxt, filename);
|
doc = parseXml(ctxt, filename);
|
||||||
|
errNo = ctxt->errNo;
|
||||||
|
#ifdef LIBXML_VALID_ENABLED
|
||||||
|
valid = ctxt->valid;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (htmlout)
|
if (htmlout)
|
||||||
xmlCtxtSetErrorHandler(ctxt, xmlHTMLError, ctxt);
|
xmlCtxtSetErrorHandler(ctxt, xmlHTMLError, ctxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doc == NULL) {
|
if (doc == NULL) {
|
||||||
if (ctxt->errNo == XML_ERR_NO_MEMORY)
|
if (errNo == XML_ERR_NO_MEMORY)
|
||||||
progresult = XMLLINT_ERR_MEM;
|
progresult = XMLLINT_ERR_MEM;
|
||||||
else
|
else
|
||||||
progresult = XMLLINT_ERR_RDFILE;
|
progresult = XMLLINT_ERR_RDFILE;
|
||||||
} else {
|
} else {
|
||||||
#ifdef LIBXML_VALID_ENABLED
|
#ifdef LIBXML_VALID_ENABLED
|
||||||
if ((options & XML_PARSE_DTDVALID) && (ctxt->valid == 0))
|
if ((options & XML_PARSE_DTDVALID) && (valid == 0))
|
||||||
progresult = XMLLINT_ERR_VALID;
|
progresult = XMLLINT_ERR_VALID;
|
||||||
#endif /* LIBXML_VALID_ENABLED */
|
#endif /* LIBXML_VALID_ENABLED */
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user